# Understanding 'solve'

I do not quite understand how 'solve' works. Consider for example:

x = var('x')
for m in (3,5,7,9,11,13):
c = cyclotomic_polynomial(m)
print solve(SR(c), x)


The output is:

[ x == -1/2*I*sqrt(3) - 1/2, x == 1/2*I*sqrt(3) - 1/2]
[
x == -1/4*sqrt(5) - 1/2*sqrt(1/2*sqrt(5) - 5/2) - 1/4,
x == -1/4*sqrt(5) + 1/2*sqrt(1/2*sqrt(5) - 5/2) - 1/4,
x == 1/4*sqrt(5) - 1/2*sqrt(-1/2*sqrt(5) - 5/2) - 1/4,
x == 1/4*sqrt(5) + 1/2*sqrt(-1/2*sqrt(5) - 5/2) - 1/4
]
[ 0 == x^6 + x^5 + x^4 + x^3 + x^2 + x + 1 ]
[
x == 1/2*I*sqrt(3)*(1/2*I*sqrt(3) - 1/2)^(1/3) - 1/2*(1/2*I*sqrt(3) - 1/2)^(1/3),
x == -1/2*I*sqrt(3)*(1/2*I*sqrt(3) - 1/2)^(1/3) - 1/2*(1/2*I*sqrt(3) - 1/2)^(1/3),
x == (1/2*I*sqrt(3) - 1/2)^(1/3),
x == 1/2*I*sqrt(3)*(-1/2*I*sqrt(3) - 1/2)^(1/3) - 1/2*(-1/2*I*sqrt(3) - 1/2)^(1/3),
x == -1/2*I*sqrt(3)*(-1/2*I*sqrt(3) - 1/2)^(1/3) - 1/2*(-1/2*I*sqrt(3) - 1/2)^(1/3),
x == (-1/2*I*sqrt(3) - 1/2)^(1/3)
]
[ 0 == x^10 + x^9 + x^8 + x^7 + x^6 + x^5 + x^4 + x^3 + x^2 + x + 1 ]
[ 0 == x^12 + x^11 + x^10 + x^9 + x^8 + x^7 + x^6 + x^5 + x^4 + x^3 + x^2 + x + 1 ]


Question: When can I expect a solution of the form "x == ..." and when not?

edit retag close merge delete

It just depends upon what Maxima's symbolic solver can do. Some cyclotomic polynomials are perhaps easier to do in terms it can expand than others?

Your answer may be technically correct. But is it not profoundly unsatisfactory considering the importance of the subject that Sage in many cases is not able to identify the roots of a cyclotomic polynomial? Note that Maple or Mathematica have no problem with it (I tested up to n=20) and give the answer as radicals or in trig form as you like. And I testify that this hurts. The effect is that if the roots are not found it often comes to explosions of symbolic expressions in formulas which make a usage of Sage pointless. In other cases it leads to computing times with the same effect. I would say an improvement is urgently needed.

I agree, but was just giving the technical answer. One thing I would recommend is trying Sympy's solver, which has apparently improved quite a lot. See my answer.

Unfortunately, to_poly_solve=True only gives numerical approximations in this case.

Sort by » oldest newest most voted

Borrowed from this answer, try the Sympy solver:

from sympy import sympify
from sympy.solvers import solve
x = var('x')
for m in (3,5,7,9,11,13,15,17,19):
c = cyclotomic_polynomial(m)
print solve(sympify(c),x)


I'm not sure why this isn't just an algorithm option, I've opened Trac 22322 for this.

more