The numerical solution for this many times in a reliable, stable way includes: (1) Forms a matrix of companions, (2) we find the eigenvalues ββof the matrix of related ones.
You might think that solving this problem is more difficult than the original, but this is how the solution is implemented in most production codes (for example, Matlab).
For polynomial:
p(t) = c0 + c1 * t + c2 * t^2 + t^3
companion matrix:
[[0 0 -c0],[1 0 -c1],[0 1 -c2]]
Find the eigenvalues ββof such a matrix; they correspond to the roots of the original polynomial.
To do this, load the routines of singular values ββfrom LAPACK very quickly, compile them and bind them to your code. Do this in parallel if you have too many (say, about a million) sets of odds.
Please note that the coefficient at t^3 is equal to one, if this is not the case in your polynomials, you will need to divide everything by a coefficient and then continue.
Good luck.
Edit: Nump and octave also depend on this methodology for computing the roots of polynomials. See, for example, this link .
source share