RJF,
The current behavior is *not* the 40-year-old behavior -- it is something
that Dodier changed (against your objections and mine if I remember
correctly) a few years ago.
The clean way to handle all this is of course some sort of lambda expression
as you say, perhaps sum(lambda([i],...), <<set expression>>). But that is
too heavy as a surface syntax -- you don't want the user to have to write
sum(lambda([i],i),integer_sequence(1,k)) instead of sum(i,i,1,k) -- and
anyway Maxima treats lambda as a barrier to simplification and doesn't have
much in the way of set expressions.
Perhaps the clean but user-friendly thing to do is to define sum(a,b,c,d) as
syntactic sugar for sum(lambda([b],a),integer_sequence(c,d)) and have the
semantics follow from that. But there are still the simplification problems
mentioned above.
Another way to approach it would be to define a sequence formalism, so that
sum(a,b,c,d) would b equivalent to sum(
make_sequence(lambda([b],a),integer_sequence(c,d) ). Even more stuff....
You could also define sum on sets as opposed to sequences, in which case the
sum would of course have to be unconditionally convergent to be
well-defined.
-s
On Sat, Feb 20, 2010 at 3:20 PM, Richard Fateman <fateman at cs.berkeley.edu>wrote:
> Robert Dodier wrote:
> ...
>
> I think we should consider making $sum an ordinary
>> argument-evaluating function, and do away with the peculiar
>> evaluation scheme which is now in place.
>>
> It's been there for 40 years. Other computer algebra systems probably do
> the same
> kind of thing. I doubt that the arguments pro and con have changed in that
> time.
> Undoubtedly a change would prompt bug reports like those from plot.
>
> In Mathematica, Sum has attribute "HoldAll". As does NIntegrate. Oddly,
> Integrate does not.
>
> As I've suggested previously, a cleaner way of doing some summation
> notation is to internalize the index, e.g.
>
> sum( lambda([i] ....expression involving i ), 1,n).
> but this seems to be unpopular with programs that muck around with the
> expression,
> not evaluating it.
>
> It would be easy to add a program, maybe call it dosum, which always
> evaluates its arguments,
> instead of changing sum.
>
> It would also be nice to allow the syntax for i:1 thru n sum f(i).
> instead of
> (s:0, for i:1 thru n do s:s+f(i), s)j. That would be like dosum, except
> better, since
> for i in [a,b,c] sum f(i) would work too.
>
> RJF
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>