sign of an expression resulting from solve()

25 views
Skip to first unread message

Alexander Tille

unread,
Nov 15, 2016, 4:25:43 AM11/15/16
to sympy
Hi guys,

I want to calculate the steady states of a system of differential equations:

   
    from sympy import *

    X
,Y,Z = symbols("X,Y,Z")
    variables_dimless
= [X,Y,Z]
   
Rxy,Rxz, Ry,Ryx,Ryz, Rz,Rzy,Rzz = symbols("Rxy,Rxz,  Ry,Ryx,Ryz,  Rz,Rzy,Rzz",positive=True)
    dimensionless_DES_list
= [X*(1-X),
                             
Ry *(Y* (1 - Y) + Rzy * Z *Y ),
                             
Rz *(Z*(1-Z)+Rxz*X*Z+Ryz*Y*Z)]
    equilibria
= solve( dimensionless_DES_list,(variables_dimless))

     
Out[2]:
     
[(0, 0, 0),
     
(0, 0, 1),
     
(0, 1, 0),
     
(0, -(Rzy + 1)/(Ryz*Rzy - 1), -(Ryz + 1)/(Ryz*Rzy - 1)),
     
(1, 0, 0),
     
(1, 0, Rxz + 1),
     
(1, 1, 0),
     
(1, -(Rxz*Rzy + Rzy + 1)/(Ryz*Rzy - 1), -(Rxz + Ryz + 1)/(Ryz*Rzy - 1))]




My problem are the negative signs of the results for example solution 4:

    (0, -(Rzy + 1)/(Ryz*Rzy - 1), -(Ryz + 1)/(Ryz*Rzy - 1)),


For future calculation it is important that all solutions of the variables have a positive sign. The solution should look like:

    (0, (Rzy + 1)/(1 - Ryz*Rzy), (Ryz + 1)/(1 - Ryz*Rzy )),



I do not know how to manipulate the output. If I define the variables as following

    X
,Y,Z = symbols("X,Y,Z",positive=True)



The solver just finds the one solution were X,Y,Z are positive.

Do you have any ideas?

Thank you in advance

Alex

Alexander Tille

unread,
Nov 15, 2016, 4:38:35 AM11/15/16
to sympy
I also tried

X,Y,Z = symbols("X,Y,Z",nonnegative=True)

Well solve() finds all solutions in this case but the solutions look the same
Reply all
Reply to author
Forward
0 new messages