Ask Your Question
0

Understanding 'solve'

asked 8 years ago

Peter Luschny gravatar image

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?

Preview: (hide)

Comments

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?

kcrisman gravatar imagekcrisman ( 8 years ago )

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.

Peter Luschny gravatar imagePeter Luschny ( 8 years ago )

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.

kcrisman gravatar imagekcrisman ( 8 years ago )

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

kcrisman gravatar imagekcrisman ( 8 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 8 years ago

kcrisman gravatar image

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.

Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 8 years ago

Seen: 302 times

Last updated: Feb 07 '17