Question: Defining a piecewise function.

Suppose I have a real function which is defined on these intervals [x0,x1],...[x1,xn], and on each interval it's defined differently, for example f(x):=sqrt(x) if x>=0; f(x):=1/x if x<0.

For the last example I tried my last resort to use the assuming operator the following way:

f := ((x -> sqrt(x)) assuming (0 <= x)) or ((x -> 1/x) assuming (x < 0)) plot(f, x)

But it doesn't seem to be working, how do you propose to define this function? perhaps proc?

I tried looking for an example in maple's help, but didn't find any.

Your help is appreciated.

Please Wait...