| 1 | initial version |
Here is a possibility:
sage: var( 'pp' );
sage: P = pp^5 + 4.61469389524440*pp^4 + (-12795.2676889452)*pp^3 + (-22752.9358658338)*pp^2 + 4.19349202517816e7*pp - 8.10593457285525e7
sage: P.polynomial(CC).roots( multiplicities=0 )
[1.93723191909898,
-81.8605754469774 - 7.33458961900103*I,
-81.8605754469774 + 7.33458961900103*I,
78.5846125398057 - 4.34280791632376*I,
78.5846125398057 + 4.34280791632376*I]
If precision is an issue, than a "better numerical field" is needed, e.g.
sage: C140 = ComplexField( prec=140 )
sage: C140(pi)
3.1415926535897932384626433832795028841972
sage: P.polynomial(C140).roots( multiplicities=0 )
[1.9372319190989844155691265074104706449442,
-81.860575446977365410019154805611554643630 - 7.3345896190010263397542664141658440115400*I,
-81.860575446977365410019154805611554643630 + 7.3345896190010263397542664141658440115400*I,
78.584612539805673040502993351629825294974 - 4.3428079163237635275011276669093668277717*I,
78.584612539805673040502993351629825294974 + 4.3428079163237635275011276669093668277717*I]
One can also use other libraries to get the (complex) roots, e.g.
sage: import numpy as np
sage: np.roots( P.coefficients(sparse=0)[::-1] )
array([-81.86057545+7.33458962j, -81.86057545-7.33458962j,
78.58461254+4.34280792j, 78.58461254-4.34280792j,
1.93723192+0.j ])
but this may be interesting only when further working with that package and the collected data, here numpy.
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.