[Maxima] proposal: subscripted local variables

Robert Dodier robert.dodier at gmail.com
Mon Mar 5 22:28:12 CST 2007

On 3/5/07, Stavros Macrakis <macrakis at alum.mit.edu> wrote:

> What's the motivation for allowing subscripted variables in
> local variable lists?

Maxima treats subscripted variables the same as symbols in some contexts.
Stuff like diff(x[1]^2, x[1]) and integrate(x[1]^2, x[1]) is OK.
But, as is too often the case, Maxima isn't consistent about that.
Why not f(x[1]) := x[1]^2 ? Or sum(g(k[1]), k[1], 1, n) for that matter.

When people write math on a piece of paper, a subscript is often just
a means of distinguishing similar symbols, and indeed Maxima
sometimes treats subscripts in just that way (as in the diff and integrate
examples above). I just want to make Maxima consistent in that respect.

>       lis: [5,6,7]$
>       lambda([a,a[1]], makelist(a[i],i,1,3))(lis,25) => [5,6,7], [25,6,7],
> or aliasing error?
>       lambda([q,a], q[1])('a,[5,6])  => 5       (current behavior)
>       lambda([q,a[1]], q[1])('a,lis) => ?
>       foo[x] := if x<0 then 0 else foo[x-1]+1$
>       [ lambda([foo[1]], foo[2] )(5), foo[1], foo[2] ] => [ 6, 1, 6 ] ???!!!
>       [ lambda([q], q[1]: 3)(lis), lis ] => [ 3, [3,6,7] ]          (current
> behavior, OK)
>       lambda([q,q[1]], q[1]:1, q) (lis,99) => [5,6,7]? or [1,6,7]?

I'll think about these examples and try to come up with some
consistent scheme for handling them. But frankly I'm not all that
worried about it. There is an analogous ambiguity which is allowed
by Maxima without comment at present. Consider f(x, x) := x^x.
What is f(a, b) ? It turns out it is b^b. Maxima makes no complaint,
neither about the definition nor the application of f.
Apparently nobody is losing sleep over it.


More information about the Maxima mailing list