ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 09 May 2022 19:37:43 +0200Strange problem with Solve functionhttps://ask.sagemath.org/question/62372/strange-problem-with-solve-function/I am running into a strange issue when trying to solve an equation, which seems pretty simple to solve. When I ask SAGE preform
x=var('x')
solve(1630*x^3 + 2991*x^2 + 1628*x + 1==0, x)
Everything goes fine, and it gives me the roots of the equation. However, when I ask it to do the same for a larger equation, I get this:
x=var('x')
solve(1953125*x^5 + 6793750*x^4 + 5942255*x^3 + 8749866*x^2 + 5857878*x + 1==0, x)
and the result is:
[0 == 1953125*x^5 + 6793750*x^4 + 5942255*x^3 + 8749866*x^2 + 5857878*x + 1]
And I do not understand why. I even checked using WolframAlpha, and the issue is not that this equation has no roots. Indeed, WolframAlpha was able to solve this equation with no issues.
What is the issue here? What am I missing?Mon, 09 May 2022 19:02:02 +0200https://ask.sagemath.org/question/62372/strange-problem-with-solve-function/Answer by dan_fulea for <p>I am running into a strange issue when trying to solve an equation, which seems pretty simple to solve. When I ask SAGE preform</p>
<pre><code>x=var('x')
solve(1630*x^3 + 2991*x^2 + 1628*x + 1==0, x)
</code></pre>
<p>Everything goes fine, and it gives me the roots of the equation. However, when I ask it to do the same for a larger equation, I get this:</p>
<pre><code>x=var('x')
solve(1953125*x^5 + 6793750*x^4 + 5942255*x^3 + 8749866*x^2 + 5857878*x + 1==0, x)
</code></pre>
<p>and the result is:</p>
<pre><code>[0 == 1953125*x^5 + 6793750*x^4 + 5942255*x^3 + 8749866*x^2 + 5857878*x + 1]
</code></pre>
<p>And I do not understand why. I even checked using WolframAlpha, and the issue is not that this equation has no roots. Indeed, WolframAlpha was able to solve this equation with no issues.</p>
<p>What is the issue here? What am I missing?</p>
https://ask.sagemath.org/question/62372/strange-problem-with-solve-function/?answer=62374#post-id-62374Solving an equation of third degree works, since we have an exact formula.
When asking for the roots of a polynomial of degree $>4$ there is no guarantee for the existence of "nice" roots. Sage generally wants to perform *exact* mathematics, so it delivers exact answers, as far as it can do it. In the above case...
sage: solve(1953125*x^5 + 6793750*x^4 + 5942255*x^3 + 8749866*x^2 + 5857878*x + 1==0, x)
[0 == 1953125*x^5 + 6793750*x^4 + 5942255*x^3 + 8749866*x^2 + 5857878*x + 1]
sage prefers to return an echo. Why? Since it cannot do better (in an *exact* manner). Well, W-Alpha is also not delivering exact results. It just gives some approximations. It is of course easy to get the approximations in sage, but we have to actively ask for numeric output. For instance:
sage: var('x');
sage: solve(1953125*x^5 + 6793750*x^4 + 5942255*x^3 + 8749866*x^2 + 5857878*x + 1==0, x, to_poly_solve=True)
[x == -2.830429732868757,
x == -0.7979018821351435,
x == (-1.70710339378983e-07),
x == (0.07496593632772452 - 1.149961450358518*I),
x == (0.07496593632772452 + 1.149961450358518*I)]
Some more options are available when asking explicitly for the roots of an algebraic expression, of a polynomial:
sage: R.<x> = PolynomialRing(QQ)
sage: f = 1953125*x^5 + 6793750*x^4 + 5942255*x^3 + 8749866*x^2 + 5857878*x + 1
sage: f.roots(ring=QQbar, multiplicities=False)
[-2.830429808252441?,
-0.7979018936926834?,
-1.707103246241551?e-7,
0.0749659363277245? - 1.149961450358519?*I,
0.0749659363277245? + 1.149961450358519?*I]
The above values are **exact**. Working with them means working with explicit exact elements in a number field.
Each value is determined by an approximation and a minimal polynomial with (exact) integral coefficients.
Well, if numerical values are wanted...
sage: f.roots(ring=CC, multiplicities=False)
[-2.83042980825244,
-0.797901893692683,
-1.70710324624155e-7,
0.0749659363277245 - 1.14996145035852*I,
0.0749659363277245 + 1.14996145035852*I]
We can of course get more decimals...
sage: myC = ComplexField(200)
sage: f.roots(ring=myC, multiplicities=False)
[-2.8304298082524409357816792805082283665446973943656659043473,
-0.79790189369268339504134957237465853264581932023615973080958,
-1.7071032462415503949697879975157140476095973540086477715140e-7,
0.074965936327724477489034174930843325380960737780780518010806 - 1.1499614503585182832508403555910655399898690410165816928866*I,
0.074965936327724477489034174930843325380960737780780518010806 + 1.1499614503585182832508403555910655399898690410165816928866*I]
----------
Note that sage comes also with a(n easy) way of seeing if the roots can be given by radicals.
We ask for the Galois group of the involved polynomial. Is it solvable?
sage: R.<x> = PolynomialRing(QQ)
sage: f = 1953125*x^5 + 6793750*x^4 + 5942255*x^3 + 8749866*x^2 + 5857878*x + 1
sage: G = f.galois_group()
sage: G
Transitive group number 5 of degree 5
sage: G.structure_description()
'S5'
sage: G.order()
120
sage: G.is_solvable()
False
No, not solvable, so there is no chance to get the solutions by radicals.
----------
Observation: Even in the case when we can obtain solutions written by radicals, e.g. for
sage: var('x');
sage: solve(x^5 -10*x^3 + 5*x^2 + 10*x +1 == 0, x)
[0 == x^5 - 10*x^3 + 5*x^2 + 10*x + 1]
sage: R.<x> = PolynomialRing(QQ)
sage: f = x^5 -10*x^3 + 5*x^2 + 10*x +1
sage: G = f.galois_group()
sage: G.is_solvable()
True
we cannot expect that sage "knows what we want", and gives us a way to digest the roots by using radicals.
Mon, 09 May 2022 19:37:43 +0200https://ask.sagemath.org/question/62372/strange-problem-with-solve-function/?answer=62374#post-id-62374