ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 17 Dec 2019 15:30:25 +0100How do I define a piecewise function with functional restrictions?https://ask.sagemath.org/question/49058/how-do-i-define-a-piecewise-function-with-functional-restrictions/ I have to define a piecewise function T(x,y) which equals x*y if x*y>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?Tue, 17 Dec 2019 15:30:25 +0100https://ask.sagemath.org/question/49058/how-do-i-define-a-piecewise-function-with-functional-restrictions/