Solving a system of polynomial equations

62 views
Skip to first unread message

Jason Moore

unread,
Jul 26, 2016, 12:12:50 PM7/26/16
to sy...@googlegroups.com
I have been working on a problem and end up needing to solve a system of nonlinear equations that are polynomials wrt to the variables of interest. There are six equations and six unknowns and only two of the variables are related non-linearly. This is the basic form:

[-c3 + 55.3719398861938],
[-c2 - 3*c3 + 1524.09472216942],
[-c1 - 3*c2 - 100*c3 - 111.682822870417*k_delta*k_phi + 16670.819288228]
[-c0 - 3*c1 - 100*c2 - 8153.56338281556*k_delta*k_phi + 3891.45616272381*k_delta + 55610.0242428841]
[-3*c0 - 100*c1 - 90978.6714602982*k_delta*k_phi + 276475.776481344]
[-100*c0 - 38237.9055133813*k_delta + 84011.44228978]

But more generally, I have symbolic coefficients. SymPy solve solves this correctly! Which is cool, but it took 4 hours to solve on my machine. I haven't tried to solve the above numerical form yet.

I'm curious if there is something I should be doing with SymPy to help it solve this faster. If I change some of the symbols to specific rationals I've had it solve as quickly as 20 minutes.

The full example is here: http://nbviewer.jupyter.org/gist/moorepants/0e85508f1b0753b01e4d9ced83e3519c/solve_inner_loop_gains.ipynb

Denis Akhiyarov

unread,
Jul 26, 2016, 5:48:26 PM7/26/16
to sympy
if you define k_delta*k_phi as another terms, e.g. c4, then k_phi disappears and the equations are linear.

Jason Moore

unread,
Jul 26, 2016, 5:57:15 PM7/26/16
to sy...@googlegroups.com
Thank you. How nice an simple.

Sounds like a strategy that could be baked into solve().

--
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/0cae5521-2adf-43ab-ba18-424e1d76a2b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages