From: David S. <d.s...@go...> - 2015-09-08 21:18:47
|
Oops, make that sinint.lisp, not sin.lisp! 2015-09-08 21:58 GMT+02:00 David Scherfgen <d.s...@go...>: > Thanks, Robert! > > I also have a patch for the integrate_use_rootsof bug. I can't believe I > actually found the spot in the code, even though I don't really understand > LISP. :-) > > All we need to do is to use a different variable inside the rootsof > expression, not the original variable of integration. This prevents the > back-substitution at the end of the integration. > > Here's a possible way to do that: > > src/sin.lisp, line 169: > - (($rootsof) ,qq)))) > + (($rootsof) ,(subst (make-param) variable qq))))) > > (%i1) integrate(1/(x^(1/3)+x+1),x),integrate_use_rootsof:true; > (%o1) > 3*'lsum((%r1^2*log(x^(1/3)-%r1))/(1+3*%r1^2),%r1,rootsof(%r2^3+%r2+1)) > > As you see, there are now two auxiliary variables, %r1 and %r2. Maybe the > second one should get a different prefix? I don't know if there is any kind > of guideline for that. > > If somebody gives me the permission, I would gladly make this my very > first Git commit to Maxima. > > Kind regards, > David > > 2015-09-08 21:47 GMT+02:00 Robert Dodier <rob...@gm...>: > >> On 2015-09-07, David Scherfgen <d.s...@go...> wrote: >> >> > the following integral results in an error "quotient by zero": >> > >> > integrate(ev(ratsimp(1/(x^(5/2)+3*x^(1/3))),algebraic),x); >> > >> > Unfortunately, I can't catch the error using errcatch. It goes right >> > through it, i.e. the whole evaluation is aborted, and I don't get any >> > result (usually, errcatch would give me an empty list if it caught an >> > error). >> >> When "quotient by zero" is encountered, 'RAT-ERR is thrown, which blows >> through 'catch' and 'errcatch'. I believe that's a bug. >> >> A solution is to call RAT-ERROR-TO-MERROR in 'catch' and 'errcatch'. I >> got that from TOPLEVEL-MACSYMA-EVAL. From what I can tell, that makes >> 'errcatch' work as expected for the above example (i.e., return an empty >> list) and obviates the need for redefining MERROR. >> >> best, >> >> Robert Dodier >> >> PS. Here is a patch. >> diff --git a/src/suprv1.lisp b/src/suprv1.lisp >> index d0c5fa4..be0a59f 100644 >> --- a/src/suprv1.lisp >> +++ b/src/suprv1.lisp >> @@ -770,14 +770,14 @@ >> (defmspec $errcatch (form) >> (let ((errcatch (cons bindlist loclist)) ret) >> (if (null (setq ret (let (*mdebug*) >> - (errset (mevaln (cdr form)) lisperrprint)))) >> + (errset (rat-error-to-merror (mevaln (cdr >> form))) lisperrprint)))) >> (errlfun1 errcatch)) >> (cons '(mlist) ret))) >> >> (defmspec $catch (form) >> (let ((mcatch (cons bindlist loclist))) >> (prog1 >> - (catch 'mcatch (mevaln (cdr form))) >> + (catch 'mcatch (rat-error-to-merror (mevaln (cdr form)))) >> (errlfun1 mcatch)))) >> >> (defmfun $throw (exp) >> >> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Maxima-discuss mailing list >> Max...@li... >> https://lists.sourceforge.net/lists/listinfo/maxima-discuss >> > > |