Subject: how can I make a variable local inside "product"?
From: Barton Willis
Date: Fri, 12 May 2006 13:34:53 -0500
The stirling function (I wrote it--not in 5.9.3, only in CVS) has a
similar problem:
(%i1) load("stirling")$
(%i2) e : sum(gamma(k),k,1,n)$
(%i3) stirling(e,1);
(%o3) sqrt(2)*sqrt(%pi)*sum(k^(k-1/2)*%e^(-k),k,1,0) <--- wrong, the sum
should extend to n
(%i4) e : sum(gamma(k),k,1,m)$
(%i5) stirling(e,1);
(%o5) sqrt(2)*sqrt(%pi)*sum(k^(k-1/2)*%e^(-k),k,1,m) <--- OK
(1) The function stirling looks like
stirling(z, [a]) := block([n, s, acc : 0, %m, pred, zerobern : true],
n : if a = [] then 1 else first(a), ...);
(2) The functions 'sum' and 'product' aren't thoroughly
documented. We should revisit the evaluation rules for
sums and products (sometime soon we should sponsor a
sum summit).
(3) Till then, I'll fix stirling (maybe).
Barton