plot [0:20] x <= 10 ? x*10 : x*x + x*10
Update : if you have more than two functions, you can use this approach:
f(x) = x <= 10 ? x \
: x <= 20 ? x**2 \
: x <= 40 ? sqrt(x) \
: x**3
and then
plot [0:40] f(x)
To clarify, the value f(x)will be:
xif xequal to or less than 10x^2if xgreater than 10 and equal to or less than 20- square root of
xif xgreater than 20 and equal to or less than 40 x^3if xmore than 40
source
share