[Maxima] sum & lsum
Richard Fateman
fateman at cs.berkeley.edu
Sun May 17 16:36:34 CDT 2009
The problem is that people don't learn about bound and unbound variables
and pure functions when they are introduced to them in courses that
teach integration or summation. Often it doesn't matter, if you keep
every name different. Computers are not smart about context, and the
programmer ends up guessing at the use patterns.
A clear way, used in RootsOf in Mathematica, but not in other places,
is to use functions, as I pointed out earlier today.
Let f(i):= i^2
then sum(f, 1, 10)
or integrate(f, 1,10)
is clear.
if you have an expression, you can write integrate( lambda([x],x^2),
1, 10)
also integrate(f) becomes lambda([i],i^3/3).
diff(f) becomes lambda([i],2*i)
etc
Not so conventional. Can this be made nice? Can this be made compatible
with current Maxima? Probably not.
RJF
Barton Willis wrote:
> Learning when to quote is an essential part of learning Maxima. So
> we should do less to protect users from unquoted expressions
> (fewer defmspec functions)---there are many cases where expressions
> must be quoted, so why protect users using sum, product, and ....?
>
> I was looking at how to support lsum(p,k, rootsof(q,x))
> expressions. The natural approach is to make lsum into a simplifying
> function. That's not difficult and it doesn't cause problems with the
> test suite. So I looked at how sum and lsum work. It's a mess.
> The user documentation doesn't help all that much.
>
> (%i1) (a : b, b : c, c : d, d : e, e : f, f : g, g : h)$
>
> (%i2) sum(a * b, b, 5,6);
> (%o2) 61
>
> (%i3) lsum(a * b, b, [5,6]);
> (%o3) 11*b
>
> (%i4) sum('a * b, b, 5,6);
> (%o4) 11*a
>
> (%i5) lsum('a * b, b, [5,6]);
> (%o5) 11*a
>
> (%i6) sum(a * 'b, b, 5,6);
> (%o6) 61
>
> (%i7) lsum(a * 'b, b, [5,6]);
> (%o7) 2*b^2
>
> (%i8) sum('(a * b), b, 5,6);
> (%o8) 11*a
>
> (%i9) lsum('(a * b), b, [5,6]);
> (%o9) 2*a*b
>
> (%i10) sum(sum(a*b,a,5,6),b,2,3);
> (%o10) 55
>
> (%i11) lsum(lsum(a*b,a,[5,6]),b,[2,3]);
> (%o11) 55
>
> (%i12) sum(sum('a*b,a,5,6),b,2,3);
> (%o12) 55
>
> (%i13) lsum(lsum('a*b,a,[5,6]),b,[2,3]);
> (%o13) 10*a
>
> (%i14) sum(sum(a*'b,a,5,6),b,2,3);
> (%o14) 55
>
> (%i15) lsum(lsum(a*'b,a,[5,6]),b,[2,3]);
> (%o15) 22*b
>
> (%i16) sum(sum('(a*b),a,5,6),b,2,3);
> (%o16) 55
>
> (%i17) lsum(lsum('(a*b),a,[5,6]),b,[2,3]);
> (%o17) 4*a*b
>
> Barton
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
More information about the Maxima
mailing list