|
From: David S. <d.s...@go...> - 2015-09-07 07:54:13
|
Hello,
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).
I've had a similar problem with questions being asked by Maxima - there is
no official way to intercept them. This is really bad if you run Maxima
"automatedly" - without anybody being there to answer questions.
But luckily, there is Robert Dodier's noninteractive package that
re-defines the Maxima functions that are responsible for asking those
questions. The re-defined functions don't ask the questions, but throw
them, so that it can be caught from the outside.
I tried to do something similar with the function that's responsible for
generating the error, the function merror in merror.lisp.
This is my attempt at it:
; If this is enabled, errors will be intercepted and thrown.
(defmvar $no_errors t)
; A wrapper around MERROR in merror.lisp.
(defvar *real-merror* (symbol-function 'merror))
(defun merror (sstring &rest l)
(if $no_errors
(meval `(($throw) '(($merror) ,sstring ,@ l)))
(apply *real-merror* sstring l)))
In a simple test case, it seems to work:
(%i1) catch(1/0);
(%o1) merror("expt: undefined: 0 to a negative exponent.")
It throws the error instead of aborting the evaluation, just as I want.
But in my original problem, it doesn't work, but crashes Maxima instead:
(%i1) catch(integrate(ev(ratsimp(1/(x^(5/2)+3*x^(1/3))),algebraic),x));
Maxima encountered a Lisp error:
Condition in MEVAL [or a callee]: INTERNAL-SIMPLE-ERROR: Bind stack
overflow.
Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.
Unfortunately, my LISP knowledge is basically nonexistent.
Does anyone of you know why this doesn't work? Why can't errcatch catch the
error in the first place? Is there something wrong with my merror wrapper?
Thanks for any help!
Best regards,
David
|