Nov-01-2020, 03:32 PM
Nov-01-2020, 03:43 PM
For solving symbolic math equations take a look at SymPy
Nov-01-2020, 03:57 PM
Or use basic algebra to solve for x then print the result
0.4x - 0.38 = 0.58
0.4x = 0.58 + 0.38 = 0.96
x = 0.96/0.4
0.4x - 0.38 = 0.58
0.4x = 0.58 + 0.38 = 0.96
x = 0.96/0.4
print(0.96/0.4)
Output:2.4
Nov-01-2020, 04:11 PM
(Nov-01-2020, 03:43 PM)deanhystad Wrote: [ -> ]For solving symbolic math equations take a look at SymPy
Thanks for the advise. But I did and I did not quite understand how I can use if for an equation similar to the one I listed above so I was hoping for a concrete solution/example.
Nov-01-2020, 04:34 PM
I have never used SymPy myself, but from this tutorial I think it looks fairly straight forward:
https://pythonforundergradengineers.com/...tions.html
My first shot would be:
https://pythonforundergradengineers.com/...tions.html
My first shot would be:
from sympy import symbols, Eq, solve x = symbols('x') eq = Eq('0.4x - 0.38 - 0.58') solution = solve((eq), (x))There may be a way to solve an equation without first putting it in the form equation = 0. I don't know.