1 | initial version |
Multiplying a string by 1.0 shouldn't work. What version of SageMath are you using? Try 9.0.
You probably want to do something like this:
sage: R.<x,z,I>=QQ[]
sage: f_str = '1.0*(x**3 + x*z +1)'
sage: f = R(sage_eval(f_str,locals={'x':x, 'z':z, 'I':I}))
sage: f.discriminant(x)
-4*z^3 - 27
If you do only sage_eval
without converting into R
, you will get a polynomial over RR
(Real Field with 53 bits of precision), because that's what the parent of 1.0
is in SageMath.
Instead of specifying the dictionary of local variables you can also lazily write locals()
, but that is less clean.