def inverse_eqn(eqn):
"""
Inverse a symbolic expression with variable x
Keeps x as the variable in the inverted expression
> inverse('4*x/2')
'y = x/2'
"""
e = sympify('-x + ' + eqn.replace('x', 'y'))
return str(solve(e, 'y')[0]).replace('x', 'float(x)')
评论列表
文章目录