Python Forum

Full Version: Algebric equation with Sympy
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi !

I have two hard equations which I tried to solve them with a numerical value by using Sympy:

from sympy import *
import sympy as sy
import math

s,v=symbols('s v')

s=((4.13 + I*568)/(4*(s+v))) -(5/6) * ((1400*s+120*I)/(v+4*I*s))

v=((570*s+I*3700)/(21*(2*v-s))) + (8/13) * ((77000*v - I*1400)/(v+s))
sol=solve([s,v],[v,s])
but I dont get s and v. What is the problem? I can not even use the nsolve. I get error
You are likely need to declare your equations (using Eq), e.g.
eq1 = Eq(((4.13 +  I ... )
eq2 = Eq(((570*s + ... )
and, finally, solve it, as you did:

solution = solve((eq1, eq2), [v, s])
print(solution)
(Jul-16-2019, 10:48 PM)scidam Wrote: [ -> ]You are likely need to declare your equations (using Eq), e.g.
eq1 = Eq(((4.13 +  I ... )
eq2 = Eq(((570*s + ... )
and, finally, solve it, as you did:

solution = solve((eq1, eq2), [v, s])
print(solution)

Thanks for the help but as I wrote my equations are :
s=((4.13 + I*568)/(4*(s+v))) -(5/6) * ((1400*s+120*I)/(v+4*I*s)) or better say:
s-((4.13 + I*568)/(4*(s+v))) -(5/6) * ((1400*s+120*I)/(v+4*I*s))=0
v=((570*s+I*3700)/(21*(2*v-s))) + (8/13) * ((77000*v - I*1400)/(v+s))
or
v-((570*s+I*3700)/(21*(2*v-s))) + (8/13) * ((77000*v - I*1400)/(v+s))=0
I tried with:
eq1=s-((4.13 + I*568)/(4*(s+v))) -(5/6) * ((1400*s+120*I)/(v+4*I*s))
eq2=v-((570*s+I*3700)/(21*(2*v-s))) + (8/13) * ((77000*v - I*1400)/(v+s))
but solution = solve((eq1, eq2), [v, s]) gaves me an empty list...
I got the solution for slightly different equations (I misunderstood you), I considered the following


eq1 = Eq(((4.13 + I*568)/(4*(s+v))) -(5/6) * ((1400*s+120*I)/(v+4*I*s))),
but you need
eq1 = Eq(s - ((4.13 + I*568)/(4*(s+v))) -(5/6) * ((1400*s+120*I)/(v+4*I*s)))
Trying to solve new equations lead to empty solution (I've tried to solve them using solve).
Are you sure that the system has a solution? Try to convert it to a polynomial form
(reduce denominators).