问题
Why doesn't the following simplification work, or how could it be fixed:
>>> x = Symbol('x', real=True)
>>> y = Symbol('y', real=True)
>>> simplify(x - 1 < y - 1)
x - 1 < y - 1
But this works:
>>> simplify(x - 1 - (y - 1) < 0)
x - y < 0
Can somehow the first expression be simplified to x < y?
Thanks
回答1:
You could solve for x:
import sympy as sy
x, y = sy.symbols('x,y', real=True)
print(sy.solve(x - 1 < y - 1, x))
yields
x < y
x, y, z = sy.symbols('x,y,z', real=True)
print(sy.solve(x - 1 < y*z - 1, x))
yields
x < y*z
来源:https://stackoverflow.com/questions/27825581/sympy-simplify-relational-inequality-expression