Solving a simple systems of equations with SymPy?

43 views
Skip to first unread message

Yuxiang Wang

unread,
Nov 24, 2014, 8:26:44 PM11/24/14
to sy...@googlegroups.com

Hi all,

I have this equation, which is Vieta's formula and is polynomial. 

SymPy code: didn't work... just hang there

from sympy.abc import x, y, z, a, b, c
from sympy import solve

solve([x+y+z-a, x*y+y*z+x*z-b, x*y*z-c], [x, y, z])

Mathematica worked.

Solve[{x + y + z == a, x y + y z + x z == b, x y z == c}, {x, y, z}]

I do know the answer of this equation, but I was wondering... this seems to be a question that should work in sympy because it does not appear too difficult to me - only polynomials. Any thoughts?


Shawn

Tim Lahey

unread,
Nov 24, 2014, 9:13:46 PM11/24/14
to sy...@googlegroups.com
Hi,

You might try the polynomial module solve support. See,

http://docs.sympy.org/latest/modules/polys/basics.html#solving-equations

Cheers,

Tim.
> --
> 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 http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/8e42eaf3-da4e-47ff-b98b-df46d1fcf2d2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Yuxiang Wang

unread,
Nov 24, 2014, 9:19:54 PM11/24/14
to sy...@googlegroups.com
Hi Tim,

Thank you! I did try that, but it still hang there...

from sympy.abc import x, y, z, a, b, c
from sympy import solve, solve_poly_system

solve_poly_system([x+y+z-a, x*y+y*z+x*z-b, x*y*z-c], [x, y, z])

In fact, I had the impression that when I used the keyboard to interrupt the solve() earlier today, it showed it is trying to use the polynomial solver.

Shawn

Tim Lahey

unread,
Nov 24, 2014, 9:29:30 PM11/24/14
to sy...@googlegroups.com
It appears that it's a bug. If you have access to GitHub, report an
issue with the details. I'd recommend including the Mathematica result
so a test case can be made.

Thanks,

Tim.
>>> an email to sympy+un...@googlegroups.com <javascript:>.
>>> To post to this group, send email to sy...@googlegroups.com
>> <javascript:>.
>>> Visit this group at http://groups.google.com/group/sympy.
>>> To view this discussion on the web visit
>>>
>> https://groups.google.com/d/msgid/sympy/8e42eaf3-da4e-47ff-b98b-df46d1fcf2d2%40googlegroups.com.
>>
>>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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 http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/ea90bce7-cca7-442e-a6e8-d95450c92c22%40googlegroups.com.

Yuxiang Wang

unread,
Nov 24, 2014, 10:27:41 PM11/24/14
to sy...@googlegroups.com
Tim,

Thanks! I generated a ticket at:


-Shawn
Reply all
Reply to author
Forward
0 new messages