The bug is in subst10 (defined in sin.lisp). A possible fix is to change (atom ex) to ($mapatom ex):
(defun subst10 (ex)
(cond ((atom ex) ex)
((and (eq (caar ex) 'mexpt) (eq (cadr ex) var))
(list '(mexpt) var (integerp2 (quotient (caddr ex) *d*))))
(t (cons (ncons (caar ex))
(mapcar #'(lambda (c) (subst10 c)) (cdr ex))))))
The function subst10 doesn't commute with expand---thus subst10 is an accident waiting to happen:
(%i22) :lisp(setf var '$x *d* 3)
3
(%i22) e : x^9 * (x+x^6);
(%o22) x^9*(x^6+x)
(%i23) expand(?subst10(e));
(%o23) x^5+x^4
(%i24) ?subst10(expand(e));
(%o24) x^5+x^3
Also (less of a potential problem)
(%i25) block([simp : false], ?subst10(x^1));
(%o25) 1
(%i27) ?subst10(x^1);
(%o27) x
Makes me wonder: Is subst10 buggy in other ways?
--Barton
________________________________________
> The result ends up with k[i] sometimes being replaced by k(i) for i=0,1. If this is reproducible it's a bug (there is no k(i) in my code).
Another example:
(%i1) x * (x^2 + k[0])/(1 + x^2);
(%o1) (x*(x^2+k[0]))/(x^2+1)
(%i2) integrate(%,x);
(%o2) ((k(0)-1)*log(x^2+1))/2+x^2/2
I'll file a bug report.
--Barton
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima