Inconsistency when using previously defined variables as arguments to functions



As I can see, you have wrong understanding on what's going on behind
the scene. Basically, Maxima has two types of functions: those which
do evaluate their arguments, as funmake() and those which do note,
like lambda()

Look at sum() example more closely. sum() has to be able to evaluate
the summation terms, but its summation variable is the _formal_
parameter, not a variable, just like "x" is a formal parameter in
(in)definite integral int(f(x),x). You have to protect the formal
variable against any attempt to interpret (evaluate) it. Calling
"ev(limit('(1/n), 'n, inf),simp);" you force Maxima to evaluate every
single parameter of the function sum(), so "'i" will also be
evaluated. This is clearly not what you want.

A similar issue would appear if you try to define a differential
operator that transforms a function into its derivative. I spent a lot
of time figuring out how it could be done; the only working way I
found was quite an awkward construction
  D(f):=
  funmake('lambda,
          [['x], diff(f('x),'x)]);
Again, this happened because you have to perform differentiation with
respect to a formal argument, not a variable "x".

Sincerely,
Ilya



On Sun, Jan 30, 2011 at 8:53 AM, thomas <thomas at geogebra.org> wrote:
> Thanks for the suggestion :)
>
> This does indeed work when simply using "limit". However, in my case (we
> call Maxima from inside another application), the call issued is actually
> "ev(limit('(1/n), 'n, inf),simp);", and in that case, it doesn't work. Any
> advice?
>
> Cheers
>
> Thomas
>
> On 01/26/2011 01:37 PM, Ilya Ryabinkin wrote:
>>
>> You may try noun form 'i istead of i
>>
>> Ilya
>>
>> On Wed, Jan 26, 2011 at 6:06 AM, thomas<thomas at geogebra.org> ?wrote:
>>>
>>> Hi there!
>>>
>>> Some commands, such as "limit" or "sum" take a "target"-variable as an
>>> argument. E.g. for limit or sum, this is the 2nd argument. However, there
>>> is
>>> an inconsistency in the way maxima behaves when this variable was
>>> previously
>>> defined:
>>>
>>>
>>> $ maxima
>>> Maxima 5.23.2 http://maxima.sourceforge.net
>>> using Lisp SBCL 1.0.40.0.debian
>>> Distributed under the GNU Public License. See the file COPYING.
>>> Dedicated to the memory of William Schelter.
>>> The function bug_report() provides bug reporting information.
>>> (%i1) i:1;
>>> (%o1) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?1
>>> (%i2) limit(1/i, i, infinity);
>>>
>>> limit: second argument must be a variable, not a constant; found: 1
>>> ?-- an error. To debug this try: debugmode(true);
>>> (%i3) sum(1/i, i, 1, 2);
>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 3
>>> (%o3) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-
>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 2
>>>
>>>
>>> Since the 2nd argument in these commands is basically "local" to the
>>> command, it is my understanding that "sum" behaves correctly in this
>>> case,
>>> while "limit" (and others like "diff") should somehow be fixed. At least
>>> that is my understanding. Would this be possible/feasible?
>>>
>>> If that's not the case: is there some way to work around this? I've tried
>>> using local and a block, but that didn't seem to work out :( Any advice?
>>>
>>> Cheers
>>>
>>> Thomas
>>> _______________________________________________
>>> Maxima mailing list
>>> Maxima at math.utexas.edu
>>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>