#12032: Symbolics code passes ungrammatical expressions to maxima
-------------------------+--------------------------------------------------
Reporter: nbruin | Owner: burcin
Type: defect | Status: new
Priority: major | Milestone: sage-4.8
Component: symbolics | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
-------------------------+--------------------------------------------------
Eviatar reports [http://groups.google.com/group/sage-
devel/browse_thread/thread/cb0a45d48756bf71 sage-devel thread]:
{{{
sage: find_maximum_on_interval(-x^2 + 9*x, 4.4, 8)
RuntimeError: ECL says: THROW: The catch MACSYMA-QUIT is undefined.
}}}
A little investigation with {{{pdb.pm()}}} shows that the error occurs in
[http://hg.sagemath.org/sage-
main/file/9e29a3d84c48/sage/interfaces/maxima_lib.py#l420
sage.interfaces.maxima_lib line 420]
{{{
if statement: result = ((result + '\n') if result else '') +
max_to_string(maxima_eval("#$%s$"%statement))
}}}
where {{{statement}}} has the value
{{{
'is (-20.247454751128636=-20.249999999999996<=-20.199549540424666)'
}}}
which is not a valid Maxima expression. The real error is in the code that
causes this to happen.
The function [http://hg.sagemath.org/sage-
main/file/9e29a3d84c48/sage/interfaces/maxima_lib.py#l160 maxima_eval] is
an ECL function, so its parameter gets converted by ECL-lib, outside
maxima_lib's control. The string contains a {{{#$...$}}} reader-macro,
which causes the maxima-parser to handle the string. It finds the syntax
error and signals it by throwing an uncaught "catch".
Invoking maxima_eval this way isn't particularly wrong, but one should
ensure that the expression passed in is at least syntactically correct. If
an error condition arises when *evaluating* the expression using
{{{maxima_eval}}}, errors are caught more gracefully.
Digging a little deeper shows that {{{find_maximum}}} should not be called
with symbolic arguments, so this particular error could be caught earlier.
However, I think the symptom shows that the symbolics code should vet its
expression a little better before passing it to maxima: The expression
isn't accepted by maxima as grammatical.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12032>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.