solving single variable two sided equation in sympy

Question:

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)
Asked By: KyleM

||

Answers:

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)
Answered By: Purusharth Malik
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.