| 1 | initial version |
You can turn your symbolic expression into a polynomial over a well-defined ring. Given the coefficients, i presume that they are floating-point numbers. Given the precision, the best "field" for that is RDF (if they had more digits of precision, you shoud have a look at RealFeld or RealBallFeld).
sage: e = pp^5 + 4.61469389524440*pp^4 - 12795.2676889452*pp^3 - 22752.9358658338*pp^2 + 4.19349202517816e7*pp - 8.10593457285525e7
sage: e.parent()
Symbolic Ring
sage: e.plot(-100,100)
Launched png viewer for Graphics object consisting of 1 graphics primitive
sage: P = e.polynomial(RDF)
sage: P
pp^5 + 4.6146938952444*pp^4 - 12795.2676889452*pp^3 - 22752.9358658338*pp^2 + 41934920.2517816*pp - 81059345.7285525
sage: P.parent()
Univariate Polynomial Ring in pp over Real Double Field
sage: P.roots()
[(1.9372319190989842, 1)]
sage: P.roots(multiplicities=False)
[1.9372319190989842]
sage: e.plot(1,2)
Just in case, if the coefficients could be described as rational or algebraic numbers, i would suggest to use them as coefficients within the correct polynomial ring so that you will get exact solutions.
| 2 | No.2 Revision |
You can turn your symbolic expression into a polynomial over a well-defined ring. Given the coefficients, i presume that they are floating-point numbers. Given the precision, the best "field" for that is RDF (if they had more digits of precision, you shoud have a look at or RealFeldRealField).RealBallFeldRealBallField
sage: e = pp^5 + 4.61469389524440*pp^4 - 12795.2676889452*pp^3 - 22752.9358658338*pp^2 + 4.19349202517816e7*pp - 8.10593457285525e7
sage: e.parent()
Symbolic Ring
sage: e.plot(-100,100)
Launched png viewer for Graphics object consisting of 1 graphics primitive
sage: P = e.polynomial(RDF)
sage: P
pp^5 + 4.6146938952444*pp^4 - 12795.2676889452*pp^3 - 22752.9358658338*pp^2 + 41934920.2517816*pp - 81059345.7285525
sage: P.parent()
Univariate Polynomial Ring in pp over Real Double Field
sage: P.roots()
[(1.9372319190989842, 1)]
sage: P.roots(multiplicities=False)
[1.9372319190989842]
sage: e.plot(1,2)
Just in case, if the coefficients could be described as rational or algebraic numbers, i would suggest to use them as coefficients within the correct polynomial ring so that you will get exact solutions.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.