I was wondering if there was any way I could get the symbolic solution for a variable in an equation using python, as I’ve been looking around but didn’t find exactly what I wanted. What I intend to do is, for example, given:
eq = x + y + 5
I’d like to get:
x = - 5 - y
Advertisement
Answer
JavaScript
x
6
1
from sympy import *
2
x, y = symbols('x, y')
3
expr = x + y + 5
4
solve(expr, x)
5
>>>Out: [-5-y]
6