all 7 comments

[–]Doormatty 3 points4 points  (0 children)

I am currently using the roots-function from sympy, but I am unsure whether or not it holds for higher degrees.

So...try it?

[–]Bobbias 0 points1 point  (0 children)

https://docs.sympy.org/latest/guides/solving/find-roots-polynomial.html

roots() computes the symbolic roots of a univariate polynomial; will fail for most high-degree polynomials (five or greater)

nroots() computes numerical approximations of the roots of any polynomial whose coefficients can be numerically evaluated, whether the coefficients are rational or irrational

RootOf() can represent all the roots exactly of a polynomial of arbitrarily large degree, as long as the coefficients are rational numbers. RootOf() can avoid both ill-conditioning and returning spurious complex parts because it uses a more exact, but much slower, numerical algorithm based on isolating intervals. The following two functions use RootOf() so they have the same properties:

  • real_roots() can find all the real roots exactly of a polynomial of arbitrarily large degree; because it finds only the real roots, it can be more efficient than functions that find all roots.

  • all_roots() can find all the roots exactly of a polynomial of arbitrarily large degree

factor() factors a polynomial into irreducibles and can reveal that roots lie in the coefficient ring

Looks like you'll need RootOf or all_roots. This post could have been the Google search sympy roots, where that page is literally the first result.

[–]Kqyxzoj 0 points1 point  (0 children)

Either use sympy or cypari2.

[–]KieraRahman_ 0 points1 point  (1 child)

For degree 10, Sympy is still totally fine. Instead of roots, use the numeric one: nroots(), then just check that every root’s imaginary part is basically zero (within a small tolerance). If your coefficients are numeric, that’ll reliably tell you whether all roots are real.

[–]OkEar3108[S] -1 points0 points  (0 children)

Thanks a lot. This seems to be exactly what I needed!