Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

solving single variable two sided equation in sympy

Can anyone advise on why the below code using Sympy would error with 'Add' object is not callable? I am trying to solve a simple single variable linear expression. It can be solved by hand and Wolfram Alpha gives a solution for ‘y’. Not sure how else to input it into Sympy. I might be less well versed in math lingo than others, so I apologize if I missed something obvious in my research.

from sympy import symbols, Eq, solve

y = symbols('y', positive=True)

lhs = ((y + 38916130600092) * (33005327976 + (y * 0.0931622))) / ((3625511843314 - (y * 0.0931622))(364312177802 - (1.02832244 * y)))
rhs =  (674255588738 - (1.001892 * y))/(692042851647 + (1.02832244 * y)) 

eq1 = Eq(lhs, rhs) 
sol = solve(eq1)
print(sol)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The problem is not with Sympy, it is simply a missed multiplication sign in your code. In Line 5, there is no multiplication sign between the two expressions which leads Python to think that you are trying to call ‘Add’ like a function.

Try the following code,

from sympy import symbols, Eq, solve
y = symbols('y', positive=True)

lhs = ((y + 38916130600092) * (33005327976 + (y * 0.0931622))) / ((3625511843314 - (y * 0.0931622))*(364312177802 - (1.02832244 * y)))
rhs =  (674255588738 - (1.001892 * y))/(692042851647 + (1.02832244 * y)) 

eq1 = Eq(lhs, rhs) 
sol = solve(eq1)
print(sol)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading