My opinions:
1. Sumhack is a respectable and useful feature.
2. Loops and Sums should be different when they are different.
Incidentally, I put sumhack into Macsyma, 35-40 years ago.
I hadn't heard that it was removed from Maxima.
Defense of these positions:
(1) It generally helps to extend the calculus of expressions to the
maximum possible domain.
That's why we allow log(x) to mean something when x might be negative.
We do not do log (abs(x)), which is what some calculus courses teach,
under their assumption
that i=sqrt(-1) is too mysterious. We believe in i.
I suppose that if you want to say that sum(f(i),i,-5, -1) is an ERROR,
that would be better than to say it is zero.
but then sum(i,i,1,n) would have to be treated by other programs as
implicitly something like if(n<1) then error else ....
which makes it tough to do things with unevaluated sums. Even
sum(i,i,1,n)- sum(i,i,1,n) is not zero.
(2) Maxima's loop construct is a programming tool. It could be made
more elaborate, say by allowing
for i:0 thru n sum i
for i:0 thru n product i
for i:0 thru n collect i ;; produces [0,1,....,n]
or many of the other things allowed by the lisp loop macro. If you care
to do these things it would be relatively harmless
unless people used them and tried to run programs on old versions of
Maxima. But even for i:0 thru n sum i is not
the same as a sum, which is a mathematical formalism with properties
like radius of convergence, and which does
not require finite bounds.
Consider the following loop/sum situation
acc:0, for i:0 thru 10 do acc: acc+(i : i^2), acc.
returns 30. 0+1+4+25
sum (i: i^2,i,0,10) returns 385
sum, you may recall, has a peculiar evaluation setup.
or compare
sum(print(5),i,1,n); which terminates with 5*n,
and the loop which cannot be executed unless 0>n can be determined.
Thnx for listening.
RJF
Robert Dodier wrote:
> On 7/26/09, Barton Willis <willisb at unk.edu> wrote:
>
>
>> Currently, we have consistency between things such as
>>
>> (%i2) f(n) := block([acc : 0], for i : 0 thru n do acc : acc + i, acc)$
>> (%i4) g(n) := sum(i,i,0,n)$
>>
>> I suppose that's good, but users should expect sums & loops to have
>> different properties.
>>
>
> Disagreed -- in the interest of predicting how different expressions
> are going to be evaluated, sums and loops should be equivalent.
>
> I'm not all that crazy about sumhack. We're going to pay a price
> for bringing it back -- namely the confusion brought on by inconsistency.
>
> Or maybe sumhack should modify the way loops work, too.
> I could be convinced of that.
>
> best
>
> Robert Dodier
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>