Hello, I am new to Sage and I want to use it to solve non-linear systems, used to model physical phenomenons. I unfortunately met some problems trying to solve a non-linear system composed of 3 polynoms (2nd order)
I first successfully solved the linear problem, but when I try with the non-linear, 2nd order system, Sage runs endlessly before finally stopping with a message error. I am using the Online version of Sage (http://www.sagenb.org). The code I wrote is pasted at the end of my message. Can anybody tell me why cannot Sage doesn't provide a solution for the non-linear system and what I am doing wrong ? I spent several days looking at my code to find any error and finding clues on the Internet, but did not find anything helpful. I finally tried using Maxima, but I observe the same behavior and no solution is given for the non-linear system. A solution nevertheless exists : I started simplifying the equations and got a 2nd order polynom over 1 variable only. Coefficients are nevertheless quite big and I want to use Sage to factorize the roots and provide general solutions. Any help would be greatly appreciated. Regards. ################# ## My code ################# Pp = var('Pp') Pm = var('Pm') s = var('s') M = var('M') gm = var('gm') #P1m, P2p and s2 are the unknowns P1p = var('P1p') P1m = var('P1m') P2p = var('P2p') P2m = var('P2m') s1 = var('s1') s2 = var('s2') M1 = var('M1') M2 = var('M2') assume(P1p > 0) assume(s1 > 0) assume(s2 > 0) assume(M1 > 0) assume(M2 > 0) # First order # ----------- print "First order resolution" print "----------------------" f1 = (1+1/M)*Pp + (1-1/M)*Pm - s f2 = ( (gm-1)*(1+M)*Pp + (gm-1)*(1-M)*Pm + s ) / (1+(gm-1)/2*M^2) f3 = s roots = solve( [f1(Pp=P1p,Pm=P1m,s=0,M=M1) - f1(Pp=P2p,Pm=0,s=s2,M=M2) == 0, \ f2(Pp=P1p,Pm=P1m,s=0,M=M1) - f2(Pp=P2p,Pm=0,s=s2,M=M2) == 0, \ f3(Pp=P1p,Pm=P1m,s=0,M=M1) - f3(Pp=P2p,Pm=0,s=s2,M=M2) == 0], \ P1m,P2p,s2) print " ", roots[0][0].factor() print " ", roots[0][1].factor() # Second order # ------------ print print "Second order resolution" print "-----------------------" f1 = (1+1/M)*Pp + (1-1/M)*Pm - s + s^2/2 - ((gm-1)*M-2)/(2*M)*Pp^2 \ - ((gm-1)*M+2)/(2*M)*Pm^2 - (gm-1)*Pm*Pp - (1+1/M)*Pp*s - (1-1/M)*Pm*s f2 = ( (gm-1)*(1+M)*Pp + (gm-1)*(1-M)*Pm + s + s^2/2 - 2*(gm-1)*Pp*Pm \ + (gm-1)*Pp*s + (gm-1)*Pm*s ) / (1+(gm-1)/2*M^2) f3 = s roots = solve( [f1(Pp=P1p,Pm=P1m,s=0,M=M1) - f1(Pp=P2p,Pm=0,s=s2,M=M2) == 0, \ f2(Pp=P1p,Pm=P1m,s=0,M=M1) - f2(Pp=P2p,Pm=0,s=s2,M=M2) == 0, \ f3(Pp=P1p,Pm=P1m,s=0,M=M1) - f3(Pp=P2p,Pm=0,s=s2,M=M2) == 0], \ P1m,P2p,s2) print " ", roots[0][0].factor() print " ", roots[0][1].factor() -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org