Ask Your Question
2

How to solve a 5-order equation in sage?

asked 2018-03-09 11:51:52 +0200

extinct gravatar image

updated 2018-03-09 14:46:25 +0200

tmonteil gravatar image

I have tried to solve the following equation:

pp^5 + 4.61469389524440*pp^4 + (-12795.2676889452)*pp^3 + (-22752.9358658338)*pp^2 + 4.19349202517816e7*pp - 8.10593457285525e7

where pp is the independent variable. the command ' solve' don't work.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2018-03-09 15:18:48 +0200

tmonteil gravatar image

updated 2018-03-09 15:24:53 +0200

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 RealField or RealBallField).

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.

edit flag offensive delete link more
2

answered 2018-03-09 15:19:49 +0200

dan_fulea gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-03-09 11:51:52 +0200

Seen: 224 times

Last updated: Mar 09 '18