Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.

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 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.