Python Forum
Algebric equation with Sympy
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Algebric equation with Sympy
#1
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
Reply
#2
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)
Reply
#3
(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...
Reply
#4
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).
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to interpret Sympy inverse_fourier_transform response ken72 3 3,609 Oct-04-2017, 09:11 PM
Last Post: Larz60+
  trying to download sympy SympyHelp 4 5,140 Apr-23-2017, 10:50 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020