From: Rupert Swarbrick <rswarbrick@us...>  20140219 21:18:45

This is an automated email from the git hooks/postreceive script. It was generated because a ref change was pushed to the repository containing the project "Maxima CAS". The branch, master has been updated via 08bf62f64b4162a765592e07424991e51b69c35d (commit) from 54f9742ab3f7399c8955d5daa084da78bdfb8022 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.  Log  commit 08bf62f64b4162a765592e07424991e51b69c35d Author: Rupert Swarbrick <rswarbrick@...> Date: Wed Feb 19 21:16:36 2014 +0000 Fix for bug #2676 The thing that was actually being tickled by the subscript in this example was ELEMXPT. Unfortunately, I think if you fix that to deal correctly with subscripted variables... you get a bind stack overflow. Eugh. So I went for a stupider fix in SININT itself, where we replace integrate (f(x[y]), x[y]) by integrate (f(z), z) (where z is a gensym, obviously) and then substitute back at the end. I think this is probably a much more robust approach than playing whackamole with all the bits of the integration code that assume variables are atomic. I don't replace all nonatomic expressions in this way. Presumably this replacement would already exist if there weren't some integration tricks we can do that are cleverer than just substituting. diff git a/src/sin.lisp b/src/sin.lisp index f2d8def..8919c77 100644  a/src/sin.lisp +++ b/src/sin.lisp @@ 1607,23 +1607,42 @@ ;; INTEGRATOR for more details. Initialize it here. (let ((*integratorlevel* 0)) (declare (special *integratorlevel*))  (cond ((mnump var) (merror (intl:gettext "integrate: variable must not be a number; found: ~:M") var))  (($ratp var) (sinint exp (ratdisrep var)))  (($ratp exp) (sinint (ratdisrep exp) var))  ((mxorlistp exp) ;; if exp is an mlist or matrix  (cons (car exp)  (mapcar #'(lambda (y) (sinint y var)) (cdr exp))))  ;; if exp is an equality, integrate both sides  ;; and add an integration constant  ((mequalp exp)  (list (car exp) (sinint (cadr exp) var)  (add (sinint (caddr exp) var)  ($concat $integration_constant (incf $integration_constant_counter)))))  ((and (atom var)  (isinop exp var))  (list '(%integrate) exp var))  ((let ((ans (simplify  (let ($opsubst varlist genvar stack) + + ;; Sanity checks for variables + (when (mnump var) + (merror (intl:gettext "integrate: variable must not be a number; found: ~:M") var)) + (when ($ratp var) (setf var (ratdisrep var))) + (when ($ratp exp) (setf exp (ratdisrep exp))) + + (cond + ;; Distribute over lists and matrices + ((mxorlistp exp) + (cons (car exp) + (mapcar #'(lambda (y) (sinint y var)) (cdr exp)))) + + ;; The symbolic integration code doesn't really deal very well with + ;; subscripted variables, so if we have one then replace occurrences of var + ;; with an atomic gensym and recurse. + ((and (not (atom var)) + (member 'array (cdar var))) + (let ((dummyvar (gensym))) + (maximasubstitute var dummyvar + (sinint (maximasubstitute dummyvar var exp) dummyvar)))) + + ;; If exp is an equality, integrate both sides and add an integration + ;; constant + ((mequalp exp) + (list (car exp) (sinint (cadr exp) var) + (add (sinint (caddr exp) var) + ($concat $integration_constant (incf $integration_constant_counter))))) + + ;; If var is an atom which occurs as an operator in exp, then return a noun form. + ((and (atom var) + (isinop exp var)) + (list '(%integrate) exp var)) + + ((let ((ans (simplify + (let ($opsubst varlist genvar stack) (integrator exp var))))) (if (sumofintsp ans) (list '(%integrate) exp var) diff git a/tests/rtest16.mac b/tests/rtest16.mac index 56ce326..d645f95 100644  a/tests/rtest16.mac +++ b/tests/rtest16.mac @@ 1884,3 +1884,7 @@ integrate(exp((1+%i)*x[1]),x[1],0,inf); /* #2688: %e^^A returns element by element exponent */ is(%e^^matrix([1,2],[3,4]) = %e^matrix([1,2],[3,4])); false$ + +/* #2676: Integral incorrect when variable is subscripted */ +integrate(x[1]*exp(x[1]), x[1]); +exp(x[1])*(x[1]1)$  Summary of changes: src/sin.lisp  53 ++++++++++++++++++++++++++++++++++++ tests/rtest16.mac  4 ++++ 2 files changed, 40 insertions(+), 17 deletions() hooks/postreceive  Maxima CAS 