Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Evaluating an expression string

For some recent computations, I devolved some initial calculus to the Maxima sub-system, and I've ended up with a list eqs of Maxima expressions. I want to transfer this list out of Maxima. This works:

sage: eqs2 = [repr(xx) for xx in eqs]

but gives me strings, which are not useful. And this:

sage: eqs2 = [sage_eval(repr(xx)) for xx in eqs]

returns the error message

NameError: name 'a43' is not defined

which is strange, as it is defined as a variable:

sage: a43
a43

I could create a list of local variables:

vars = {'a21':a21,'a31':a31}

and so on, and use

sage_eval(xx,vars)

but as there are 20 more variables, this would be tedious.

Is there a better way?

Evaluating Difficulties evaluating an expression string

For some recent computations, I devolved some initial calculus to the Maxima sub-system, and I've ended up with a list eqs of Maxima expressions. I want to transfer this list out of Maxima. This works:

sage: eqs2 = [repr(xx) for xx in eqs]

but gives me strings, which are not useful. And this:

sage: eqs2 = [sage_eval(repr(xx)) for xx in eqs]

returns the error message

NameError: name 'a43' is not defined

which is strange, as it is defined as a variable:

sage: a43
a43

I could create a list of local variables:

vars = {'a21':a21,'a31':a31}

and so on, and use

sage_eval(xx,vars)

but as there are 20 more variables, this would be tedious.

Is there a better way?