multiple evaluations & integrate



On 2013-06-08, Barton Willis <willisb at unk.edu> wrote:

> Not OK:
>
>   (%i3) (a:b,b:c,c:d,d:e,e:f,f:g,g:h,h:i)$
>
>   (%i4) integrate(sin(2 *asin(a*x)), x);
>   (%o4) ((1-f^2*x^2)^(3/2)+sqrt(1-f*x)*sqrt(f*x+1)*(5*f^2*x^2-5))/(6*f)
>
> In risch.lisp, I see things such as
>
>   (let ((*in-risch-p* t))  (meval (list '($ev) result '$nouns)))
>
> I'm not sure that appending '$noeval fixes the (putative) bug.

No, it doesn't fix the bug, although it does show that those calls
to MEVAL are only part of the trouble ...

(%i2) load (risch);
(%o2) "/home/robert/maxima/maxima-git/maxima-code/src/risch.lisp"
(%i3) (a:b,b:c,c:d,d:e,e:f,f:g,g:h,h:i)$
(%i4) integrate(sin(2 *asin(a*x)), x);
(%o4) (sqrt(1-d*x)*sqrt(d*x+1)*(5*d^2*x^2-5)
 -3*d^2*'integrate(x*sqrt(1-d*x)*sqrt(d*x+1),x))
 /(6*d)
(%i5) %, nouns;
(%o5) ((1-e^2*x^2)^(3/2)+sqrt(1-e*x)*sqrt(e*x+1)*(5*e^2*x^2-5))/(6*e)

noeval prevents risch from solving the integral which shows up as an
intermediate result, but by that time a has been evaluated a few times,
it appears.

Maybe if solving integrals were a simplification, the problem would go
away? I realize that would require reworking some code (maybe a lot).

> I think (%o4) shows a bug. Is the Maxima  evaluation policy clearly
> documented?

I don't know where it is documented -- but it is certainly a strong
and usually-honored convention, anyway. I agree it's a bug, btw.

best

Robert Dodier

PS. Here are the modifications to risch.

$ git diff src/risch.lisp
diff --git a/src/risch.lisp b/src/risch.lisp
index b472dd7..349488f 100644
--- a/src/risch.lisp
+++ b/src/risch.lisp
@@ -179,7 +179,7 @@
         ;; Set the flag *in-risch-p* to make sure that we do not call
         ;; rischint again from the integrator. This avoids endless loops.
         (let ((*in-risch-p* t)) 
-          (meval (list '($ev) result '$nouns)))
+          (meval (list '($ev) result '$nouns '$noeval)))
         result)))
 
 (defun trigin1 (*exp var)
@@ -196,7 +196,7 @@
           ;; Set the flag *in-risch-p* to make sure that we do not call
           ;; rischint again from the integrator. This avoids endless loops.
           (let ((*in-risch-p* t)) 
-            (meval (list '($ev) result '$nouns)))
+            (meval (list '($ev) result '$nouns '$noeval)))
           result))))
 
 (defun tryrisch (exp mainvar)