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)

2 answers

Concerning your second definition, as @paulmasson, i can not reproduce your problem.

Concerning you first definition, there is something tricky about symbolics to understand: when you write g(x) = max(f(x),0), the Python builtin max is used, which takes the max between two Python/Sage objects f(x) and 0, not pointwise! Since those two objects are not comparable, it considers that the first is to be returned, so max(f(x),0) is nothing but the object f(x). You can check by changing the order max(0,f(x)):