As for example, consider a piecewise function for calculating domain and range.

For calculating the domain of piecewise function, together with the union of those three intervals from the three sub-functions conditions. So the domain=(-∞, 0)∪[0, 1]∪(1, ∞)=(-∞, ∞)

Calculating the range of this piecewise function:

For the First sub-function f(x)=x^{2} where x<0 , we can get the range interval 0^{2}+1<f(x)<(-∞)^{2}+1 ⇒ 0<f(x)<∞

For the second sub-function f(x)=x where 0 ≤ x≤ 1 , we can get the range interval f(0) ≤ f(x) ≤ f(1) ⇒ 0 ≤ f(x) ≤ 1

For the Third sub-function f(x)=1/x where x>1 , we can get the range interval 1/f(∞) < f(x) < 1/f(1) ⇒ 1/∞ < f(x) < 1/1 ⇒ 0 < f(x) < 1

Now together with the union of this three range intervals, we get the range=(0, ∞)∪[0, 1]∪(0, 1)=[0, ∞)

Now again from the graph of this piecewise funtion, we see the graph is situated from left to right all over x-axis, so the domain=(-∞, ∞) and the graph is situated from origin to upper side all over the positive y-axis, so the range=[0,∞)

Domain and Range of a piecewise function can be guess from its graph.