Ask Your Question
0

Understanding 'solve'

asked 2017-02-07 04:41:54 -0500

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?

edit retag flag offensive close merge delete

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 ( 2017-02-07 06:47:41 -0500 )edit

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 ( 2017-02-07 09:17:42 -0500 )edit

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 ( 2017-02-07 10:26:21 -0500 )edit

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

kcrisman gravatar imagekcrisman ( 2017-02-07 10:31:58 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-02-07 10:30:41 -0500

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.

edit flag offensive delete link more

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: 2017-02-07 04:41:54 -0500

Seen: 71 times

Last updated: Feb 07