Help: simple univariate polynomial, sympy solve gives no results

59 views
Skip to first unread message

Junwei Huang

unread,
Jan 19, 2016, 9:37:18 PM1/19/16
to sympy
Hello, I am new to sympy and try to solve the following equation

import sympy as sy
A,B,C,D,x=sy.var('A,B,C,D,x',positive=True)
sy.solve(A*x**5+B*x**4+C*x-D,x)

but got no result. There are no roots, or I used it in a wrong way? Thanks



Denis Akhiyarov

unread,
Jan 20, 2016, 12:41:47 AM1/20/16
to sympy
no algebraic roots according to this theorem: https://en.wikipedia.org/wiki/Abel%E2%80%93Ruffini_theorem

Denis Akhiyarov

unread,
Jan 20, 2016, 12:46:59 AM1/20/16
to sympy
actually this case looks like has some special properties and hence has some roots according to Wolfram:

Oscar Benjamin

unread,
Jan 20, 2016, 4:55:37 AM1/20/16
to sympy
On 20 January 2016 at 05:46, Denis Akhiyarov <denis.a...@gmail.com> wrote:
> On Tuesday, January 19, 2016 at 11:41:47 PM UTC-6, Denis Akhiyarov wrote:
>>
>> no algebraic roots according to this theorem:
>> https://en.wikipedia.org/wiki/Abel%E2%80%93Ruffini_theorem

The theorem only shows that a general algebraic solution for *all*
quintics (or higher degree polynomials) is not possible. In this case
it is not a fully general quintic since the coefficients of x^3 and
x^2 are both zero. I'm not sure how to check based on the coefficients
of a polynomial whether or not its Galois group is solvable. Can sympy
do that?

To the OP: do you need to solve this in terms of symbols A, B etc. or
is it acceptable to solve it using particular numbers for the
coefficients? You may have better luck using the actual numbers.

> actually this case looks like has some special properties and hence has some
> roots according to Wolfram:
>
> http://www.wolframalpha.com/input/?i=A*x%5E5%2BB*x%5E4%2BC*x-D%3D0

My interpretation of that Wolfram output is that Wolfram is unable to
solve this quintic (or rather this general family of quintics).

--
Oscar

Denis Akhiyarov

unread,
Jan 20, 2016, 10:05:40 AM1/20/16
to sympy
Oscar, you need to click on "more roots" in wolfram alpha to see the algebraic solution, which is definitely confusing.

Aaron Meurer

unread,
Jan 20, 2016, 10:12:16 AM1/20/16
to sy...@googlegroups.com
SymPy has algorithms to find roots of quintics in radicals (when they exist). I don't recall if the algorithms work for symbolic inputs. 

One can take a general quintic (x**5 + a*x**4 + b*x**3 + c*x**2 + d*x + e) and shift it by y (replace x with x - y). Then expand and collect terms in x. The coefficient of x**3 is a quadratic in y.  Hence, one can solve a quadratic in y in radicals terms of a and b, and shift the quintic by that. One then has a new quintic, with no cubic term, with the same roots shifted by some term which is expressible in radicals. Hence, the general quintic with no cubic term is not solvable in radicals, as a solution would give a solution to the general quintic (shift it back by the radical expression above, which would keep it in radicals). 

Here is some SymPy code:

a, b, c, d, e, x, y = symbols('a b c d e x y')
q = x**5 + a*x**4 + b*x**3 + c*x**2 + d*x + e
print(collect(q.subs(x, x - y).expand(), x, evaluate=False)[x**3])
t = solve(collect(q.subs(x, x - y).expand(), x, evaluate=False)[x**3], y)[0]
print(t)
print(collect(q.subs(x, x - t).expand(), x, evaluate=False).get(x**3))

Aaron Meurer


--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAHVvXxSwgubqczYcavJ%2BBQVah0aR05dda-0fS4VPubBTajHizw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Oscar Benjamin

unread,
Jan 20, 2016, 10:12:42 AM1/20/16
to sympy
On 20 January 2016 at 15:05, Denis Akhiyarov <denis.a...@gmail.com> wrote:
>
> Oscar, you need to click on "more roots" in wolfram alpha to see the
> algebraic solution, which is definitely confusing.

Unless I'm misreading all of the additional roots are for the case
where A=0. IOW Wolfram is saying "hey if by any chance A=0 then this
would be a quartic and I would know how to get the roots of that". My
interpretation then is that if A != 0 so that it's a true quintic then
Wolfram can't solve it.

--
Oscar

Aaron Meurer

unread,
Jan 20, 2016, 10:13:34 AM1/20/16
to sy...@googlegroups.com
WolframAlpha is solving for all five variables at once. The roots in radicals that it gives are when A = 0 (in which case, you have a quartic, which are solvable in radicals). 

Aaron Meurer

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.

Oscar Benjamin

unread,
Jan 20, 2016, 10:30:38 AM1/20/16
to sympy
On 20 January 2016 at 15:11, Aaron Meurer <asme...@gmail.com> wrote:
> SymPy has algorithms to find roots of quintics in radicals (when they
> exist). I don't recall if the algorithms work for symbolic inputs.
>
> One can take a general quintic (x**5 + a*x**4 + b*x**3 + c*x**2 + d*x + e)
> and shift it by y (replace x with x - y). Then expand and collect terms in
> x. The coefficient of x**3 is a quadratic in y. Hence, one can solve a
> quadratic in y in radicals terms of a and b, and shift the quintic by that.
> One then has a new quintic, with no cubic term, with the same roots shifted
> by some term which is expressible in radicals. Hence, the general quintic
> with no cubic term is not solvable in radicals, as a solution would give a
> solution to the general quintic (shift it back by the radical expression
> above, which would keep it in radicals).

The above argument extends to making any of the coefficients zero with
the exception of the constant coefficient e. If we could shift to x -
t so that we have a new polynomial with zero constant term then x = t
would be a root of the original polynomial which would imply being
able to find one root of (and hence all roots of) any quintic.
Otherwise though we can shift to make any of a, b, c or d zero.

However the OP asked about a less general case where the cubic and
quadratic coefficients are both zero. It's not possible in general to
shift a quintic so that both b and c are zero.

> Here is some SymPy code:
>
> a, b, c, d, e, x, y = symbols('a b c d e x y')
> q = x**5 + a*x**4 + b*x**3 + c*x**2 + d*x + e
> print(collect(q.subs(x, x - y).expand(), x, evaluate=False)[x**3])
> t = solve(collect(q.subs(x, x - y).expand(), x, evaluate=False)[x**3], y)[0]
> print(t)
> print(collect(q.subs(x, x - t).expand(), x, evaluate=False).get(x**3))

To make b and c zero we'd need to solve these two equations
simultaneously for one variable y:

In [5]: print(collect(q.subs(x, x - y).expand(), x, evaluate=False)[x**2])
6*a*y**2 - 3*b*y + c - 10*y**3

In [6]: print(collect(q.subs(x, x - y).expand(), x, evaluate=False)[x**3])
-4*a*y + b + 10*y**2

Clearly that will only work for some lucky values of a, b, and c. (One
that jumps out is the trivial solution that we could have y=0 if b and
c are both 0.)

So this is not a general quintic but neither sympy nor Wolfram can
solve it. I was wondering if it is possible to specifically verify
that it has an unsolvable Galois group but perhaps not.

--
Oscar

Aaron Meurer

unread,
Jan 20, 2016, 10:38:17 AM1/20/16
to sy...@googlegroups.com
On Wed, Jan 20, 2016 at 10:30 AM, Oscar Benjamin <oscar.j....@gmail.com> wrote:
On 20 January 2016 at 15:11, Aaron Meurer <asme...@gmail.com> wrote:
> SymPy has algorithms to find roots of quintics in radicals (when they
> exist). I don't recall if the algorithms work for symbolic inputs.
>
> One can take a general quintic (x**5 + a*x**4 + b*x**3 + c*x**2 + d*x + e)
> and shift it by y (replace x with x - y). Then expand and collect terms in
> x. The coefficient of x**3 is a quadratic in y.  Hence, one can solve a
> quadratic in y in radicals terms of a and b, and shift the quintic by that.
> One then has a new quintic, with no cubic term, with the same roots shifted
> by some term which is expressible in radicals. Hence, the general quintic
> with no cubic term is not solvable in radicals, as a solution would give a
> solution to the general quintic (shift it back by the radical expression
> above, which would keep it in radicals).

The above argument extends to making any of the coefficients zero with
the exception of the constant coefficient e. If we could shift to x -
t so that we have a new polynomial with zero constant term then x = t
would be a root of the original polynomial which would imply being
able to find one root of (and hence all roots of) any quintic.
Otherwise though we can shift to make any of a, b, c or d zero.

However the OP asked about a less general case where the cubic and
quadratic coefficients are both zero. It's not possible in general to
shift a quintic so that both b and c are zero.

Oh I didn't notice that :) 


> Here is some SymPy code:
>
> a, b, c, d, e, x, y = symbols('a b c d e x y')
> q = x**5 + a*x**4 + b*x**3 + c*x**2 + d*x + e
> print(collect(q.subs(x, x - y).expand(), x, evaluate=False)[x**3])
> t = solve(collect(q.subs(x, x - y).expand(), x, evaluate=False)[x**3], y)[0]
> print(t)
> print(collect(q.subs(x, x - t).expand(), x, evaluate=False).get(x**3))

To make b and c zero we'd need to solve these two equations
simultaneously for one variable y:

In [5]: print(collect(q.subs(x, x - y).expand(), x, evaluate=False)[x**2])
6*a*y**2 - 3*b*y + c - 10*y**3

In [6]: print(collect(q.subs(x, x - y).expand(), x, evaluate=False)[x**3])
-4*a*y + b + 10*y**2

Clearly that will only work for some lucky values of a, b, and c. (One
that jumps out is the trivial solution that we could have y=0 if b and
c are both 0.)

So this is not a general quintic but neither sympy nor Wolfram can
solve it. I was wondering if it is possible to specifically verify
that it has an unsolvable Galois group but perhaps not.

SymPy is not able to do that (I checked and the roots_quintic function in the polys only works for rational coefficients). 

If WolframAlpha can compute Galois groups I wasn't able to get it to work. Probably GAP can do it, if someone wants to check that.

Aaron Meurer
 

--
Oscar

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.

Denis Akhiyarov

unread,
Jan 20, 2016, 11:05:14 AM1/20/16
to sy...@googlegroups.com

I missed A=0 on wolfram, sorry for confusion


You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/sFNgH5zRNm0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+un...@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.

Kalevi Suominen

unread,
Jan 20, 2016, 3:53:32 PM1/20/16
to sympy

It seems that this polynomial equation is not solvable by radicals in general. A general quintic
 x**5 + a*x**4 + b*x**3 + c*x**2 + d*x + e  can be transformed into the Bring-Jerrard normal form
x**5 + d*x + e  (https://en.wikipedia.org/wiki/Bring_radical#Bring.E2.80.93Jerrard_normal_form) which is solvable only under special conditions between its two coefficients.
Reply all
Reply to author
Forward
0 new messages