(%i3) sum(if k < n then 0 else %pi,k,0,n);
Maxima was unable to evaluate the predicate:
g33546<n
The error about a gensym variable is going to
flummox users. Quoting the summand eliminates the problem:
(%i8) sum('(if k < n then 0 else %pi),k,0,n);
(%o8) sum(if k<n then 0 else %pi,k,0,n)
(It would be nice if Maxima evaluated this sum to %pi.)
Maybe mevalsumarg should set $prederror to nil:
(defun mevalsumarg (expr ind low hi sump)
(let (($prederror nil))
Doing this triggers a bug (unrelated to the
summation code):
(%i2) sum(if k < n then 0 else %pi,k,0,n);
(%o2) (n+1)*(if unknown then 0 else %pi)
Boolsimp corrects this bug:
(%i3) load(boolsimp);
(%i4) sum(if k < n then 0 else %pi,k,0,n);
(%o4) sum(if k<n then 0 else %pi,k,0,n)
I don't know what is best.
Robert Dodier
2007-01-13
Logged In: YES
user_id=501686
Originator: NO
(1) I think the solution is move boolsimp into src.
(2) In the absence of boolsimp, maybe sum should just catch all errors and return a noun expression. Ugh.
(2) sum(if k <= n then 0 else %pi, k, 0, n) => 0 (Since in this case Maxima successfully evaluates is(k <= n) with assumptions k >= 0, k <= n.)