Function with a lower limit
I need to define a function like the following:
y = 5 - 2x if f(x)>0
0 otherwise
I tried different solutions:
f(x) = 5 - 2*x
g(x) = max(f(x),0)
or:
f(x) = 5 - 2*x
def g(x):
return f(x) if f(x)>0 else 0
However, when I try to plot them, they do not seem to work: the first ignores the lower bound, while the second is always zero. This is strange, as when I try [g(x) for x in range(0,10)]
it returns the correct values of g(x)