[Maxima] proposal: subscripted local variables
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^2, x) and integrate(x^2, x) is OK.
But, as is too often the case, Maxima isn't consistent about that.
Why not f(x) := x^2 ? Or sum(g(k), k, 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], makelist(a[i],i,1,3))(lis,25) => [5,6,7], [25,6,7],
> or aliasing error?
> lambda([q,a], q)('a,[5,6]) => 5 (current behavior)
> lambda([q,a], q)('a,lis) => ?
> foo[x] := if x<0 then 0 else foo[x-1]+1$
> [ lambda([foo], foo )(5), foo, foo ] => [ 6, 1, 6 ] ???!!!
> [ lambda([q], q: 3)(lis), lis ] => [ 3, [3,6,7] ] (current
> behavior, OK)
> lambda([q,q], q: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