Re: Trouble solving nonlinear system of equations

55 views
Skip to first unread message
Message has been deleted

Alexander Tille

unread,
Nov 17, 2016, 5:07:26 AM11/17/16
to sympy
Hi,

It is really hard to read/understand your formula.

can you substitute all your numbers like 0.749922055929781 by some variables. This will make your formula more readable.
And can you also print out the command latex(your_formula) so I can read your formula better.

At a first glance I can simplify your formula by hand to shorter version (term like) in the denominator.
So try to simplify your formula by hand or with the command formula.simplify().

Maybe solve() will be faster this time.

Good luck!


Am Mittwoch, 16. November 2016 23:41:59 UTC+1 schrieb Eduardo Rivera:
Hi, I'm trying to solve this system of nonlinear equations, however after and hour it looks like it won't make it very soon.

I read up and found that solveset was the way to go into the future, however the 1.0 version if sympy that I'm using apparently doesn't have solveset.nonlinsolve(). As of now I was forced to use old regular solve. Here is my input:


res=solve([expr1,expr2,expr3,expr4], [la1,la2,la3,la4],set=true)

Where the first expression is like this:

-0.005*lambda_1*(-1.01*lambda_1 + 2/(1 + 0.749922055929781/lambda_1))/(-0.995*lambda_1*(lambda_1 - 1/(1 + 0.749922055929781/lambda_1)) + 0.995*lambda_1/(1 + 0.749922055929781/lambda_1) - 0.995*lambda_2*(lambda_2 - 1/(1 + 1.12753540370512/lambda_2)) + 0.995*lambda_2/(1 + 1.12753540370512/lambda_2) - 0.995*lambda_3*(lambda_3 - 1/(1 + 1.82344707450068/lambda_3)) + 0.995*lambda_3/(1 + 1.82344707450068/lambda_3) - 0.995*lambda_4*(lambda_4 - 1/(1 + 6.27879834162764/lambda_4)) + 0.995*lambda_4/(1 + 6.27879834162764/lambda_4) + 1.005) - 0.005*lambda_1 + 0.005*lambda_1/(-0.995*lambda_1*(lambda_1 - 1/(1 + 0.749922055929781/lambda_1)) + 0.995*lambda_1/(1 + 0.749922055929781/lambda_1) - 0.995*lambda_2*(lambda_2 - 1/(1 + 1.12753540370512/lambda_2)) + 0.995*lambda_2/(1 + 1.12753540370512/lambda_2) - 0.995*lambda_3*(lambda_3 - 1/(1 + 1.82344707450068/lambda_3)) + 0.995*lambda_3/(1 + 1.82344707450068/lambda_3) - 0.995*lambda_4*(lambda_4 - 1/(1 + 6.27879834162764/lambda_4)) + 0.995*lambda_4/(1 + 6.27879834162764/lambda_4) + 1.005)

Maybe I should try a numeric solve, but in an ideal world some of this numbers are variables, I'm just trying to solve first for a particular case.

Is there a way to maybe optimize this? Any help is greatly appreciated, as this is for my thesis xd

Denis Akhiyarov

unread,
Nov 21, 2016, 11:28:01 PM11/21/16
to sympy
For numerical solution you may want to use scipy:

https://groups.google.com/forum/m/#!topic/sympy/gIFados9AJo

Björn Dahlgren

unread,
Nov 22, 2016, 1:27:02 PM11/22/16
to sympy


On Tuesday, 22 November 2016 05:28:01 UTC+1, Denis Akhiyarov wrote:
For numerical solution you may want to use scipy:

https://groups.google.com/forum/m/#!topic/sympy/gIFados9AJo


Shameless plug: if you are solving a symbolically defined system numerically, you may
want to try pyneqsys (which supports SymPy foremost) if you have a symbolic system.

Regards,
Björn
Reply all
Reply to author
Forward
0 new messages