Ask Your Question
0

About roots of a certain polynomial equation

asked 2015-01-20 21:55:47 +0100

phoenix gravatar image

updated 2015-01-21 10:27:45 +0100

tmonteil gravatar image

Why is Sage hanging up trying to find roots of this equation?

0 = (x^2 - 6.00000000000000)*x^2 - 4*x*(e^(2/5*I*pi) + e^(-2/5*I*pi)) - e^(4/5*I*pi) - e^(-4/5*I*pi) - 1
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2015-01-21 10:23:43 +0100

tmonteil gravatar image

updated 2015-01-21 10:42:01 +0100

The answer is somehow similar to that one. It is important to know where your objects are living and define them into the right place. As for mathematics, Sage will not be able to handle ill-defined expressions consistently.

First, when you write 6.00000000000000 you define a numerical (floating-point, i.e. approximated) number:

sage: 6.00000000000000.parent()
Real Field with 53 bits of precision

While, when you write e^(-2/5*I*pi), you define a symbolic expression:

sage: (e^(-2/5*I*pi)).parent()
Symbolic Ring

So, if you want something exact, you have to replace 6.00000000000000 by 6, which is an exact integer:

sage: 6.parent()
Integer Ring

Also, e^(-2/5*I*pi) is not any complex number, but an algebraic one, so you should take the benefit of this.

Then, your function is not a genuine polynomial but a symbolic expression (you could also have cos(log(x)) in such expression for example):

sage: p = (x^2 - 6)*x^2 - 4*x*(e^(2/5*I*pi) + e^(-2/5*I*pi)) - e^(4/5*I*pi) - e^(-4/5*I*pi) - 1
sage: p.parent()
Symbolic Ring

So, let us transform it into a genuine polynomial defined on the field of (complex) algebraic numbers:

sage: P = p.polynomial(QQbar)
sage: P.parent()
Univariate Polynomial Ring in x over Algebraic Field

The Univariate Polynomial Ring in x over Algebraic Field makes more sense than a mysterious Symbolic Ring, isn't it ?

In this safer place, you can have a look at its roots:

sage: P.roots()
[(-2.175570504584946? + 0.?e-17*I, 1),
 (-0.618033988749895? + 0.?e-17*I, 1),
 (0.1755705045849463? + 0.?e-18*I, 1),
 (2.618033988749895? + 0.?e-17*I, 1)]
edit flag offensive delete link more
0

answered 2015-07-15 15:45:45 +0100

rws gravatar image

Actually, Sage can solve your form symbolically as soon as you replace 6.0 with 6 and apply simplify_rectform:

sage: ((x^2 - 6)*x^2 - 4*x*(e^(2/5*I*pi) + e^(-2/5*I*pi)) - e^(4/5*I*pi) - e^(-4/5*I*pi) - 1).simplify_rectform()
(x^2 - 6)*x^2 - 2*x*(sqrt(5) - 1) + 1/2*sqrt(5) - 1/2
sage: solve(_,x)
[x == -1/2*sqrt(-2*sqrt(5) + 10) - 1, x == 1/2*sqrt(-2*sqrt(5) + 10) - 1, x == -1/2*sqrt(2*sqrt(5) + 6) + 1, x == 1/2*sqrt(2*sqrt(5) + 6) + 1]
edit flag offensive delete link more
0

answered 2015-01-20 23:57:21 +0100

Rolandb gravatar image

updated 2015-01-20 23:58:54 +0100

I assume you are wondering why Sage is not recognizing that $(x^2 - 6)x^2 - 4x(e^{\frac{2}{5}i\pi} + e^{\frac{-2}{5}i\pi}) - e^{\frac{4}{5}i\pi} - e^{\frac{-4}{5}i\pi} - 1=(x^2 - 6)x^2 - 8xcos(\frac{2}{5}\pi) - 2*cos(\frac{4}{5}\pi) - 1$, and thereafter doesn't find the four real roots: $x=-2.1755705045849463, -0.618033988749891, 0.17557050458494627, 2.618033988749895$.

Mixing the world of solving algebraic equations - which are exact - with the world of finding roots - which are approximations - is seldom a good idea. If you would split both worlds, it goes fluently.

var('x')
f(x)=(x^2 - 6)*x^2 - 4*x*(e^(2/5*I*pi) + e^(-2/5*I*pi)) - e^(4/5*I*pi) - e^(-4/5*I*pi) - 1
g(x)=real_part(f(x)).simplify()
print g
x |--> x^4 - 6*x^2 - 2*sqrt(5)*x + 2*x + 1/2*sqrt(5) - 1/2

print [find_root(g,-3,-2), find_root(g,-1,0), find_root(g,0,1), find_root(g,2,3)]
[-2.1755705045849463, -0.6180339887498911, 0.17557050458494627, 2.618033988749895]

Stated differently, always simplify your function (= exact) before going into a numerical process such as root finding. Any system - thus also Sage - hangs up because it is impossible to determine the simplification numerically.

edit flag offensive delete link more

Comments

@Rolandb Why did you remove the imaginary part of the function? And since this is a quartic equation, shouldn't it be able to tell me the exact roots in terms of square-roots?

Phoenix gravatar imagePhoenix ( 2015-01-21 01:02:54 +0100 )edit

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2015-01-20 21:55:47 +0100

Seen: 3,711 times

Last updated: Jul 15 '15