I have to define a piecewise function T(x,y) which equals xy if xy>0 and x+y for x*y<=0. How do I do this? I have tried in this way:
def T(x,y):
if (x>0):
return x*y
else:
return x+y
but it does not work. How can I solve this problem?
| 1 | initial version |
I have to define a piecewise function T(x,y) which equals xy if xy>0 and x+y for x*y<=0. How do I do this? I have tried in this way:
def T(x,y):
if (x>0):
return x*y
else:
return x+y
but it does not work. How can I solve this problem?
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.