Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to evaluate a constructed expression

Hi. The example below is self explanatory

hexp= "g(x)=" + "x**3"
print(hexp)
eval(hexp)
print(g(2))

The hexp is something that is built according to a given algorithm. What I get is the following (on another example)

f(x)= (-1*x**0+4*x**1-1*x**2) * (-5*x**0+5*x**1+4*x**2) * (2*x**0-5*x**1-5*x**2)    
     ^
SyntaxError: invalid syntax

Tried also with evalf without success. Any help will be appreciated.