Reputation: 13
How would I implement the following in Sympy?
if x > y
z = x - y
otherwise
Z = 0
I've looked at assumptions, but I am still lost.
Upvotes: 1
Views: 243
Reputation:
Please see the examples on this page.
import sympy as s
x, y = s.symbols('x,y')
z = s.Piecewise( ( x-y, x > y), (0, True))
z.subs([(x,1),(y,2)])
z.subs([(x,2),(y,1)])
Upvotes: 2