简体   繁体   中英

Python: Equation symbolic solution

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

from sympy import *
x, y = symbols('x, y')
expr = x + y + 5
solve(expr, x)
>>>Out: [-5-y]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM