Finding Polynomial Roots Using Python - Possible Error Increasing Noise

I use Numpy to get polynomial roots. Numpy provides a polynomial module.

My hand calculates for 'x * 2 + 5 * x + 6 = 0' * is 'x = -2' and 'x = -3'. (Simple)

But my code shows me the wrong answer: array ([- 0.5, -0.33333333]) (Inversed?)

Can anyone find the culprit in my code? Or is it just a mistake?

from numpy.polynomial import Polynomial as P p = P([1, 5, 6]) p.roots() 
+8
numpy polynomial-math
source share
2 answers

Just pass it in a different order,

 p = P([6, 5, 1]) 
+10
source share

You could realize this yourself if you determined that for a polynomial P degree n , R(x) = x^n P(1/x) is equal to the inverted version of P Thus, with the exception of 0 , the roots of R are inverse to the roots of P

-one
source share

All Articles