Answer
See below.
Work Step by Step
A function is a rule by which to each input from the domain, a unique value from the range is assigned.
If we define a different rule for different subsets of the domain, then we define the function "in pieces", or piecewise.
(For each subset, a different rule.)
$\text{Example 1.}$
Define a real-valued function of a real variable such that
- for negative x, let the function value be double of x,
- for nonnegative x, let the function value be half of x.
$f(x)=\left\{\begin{array}{lll}
2x, & for & x\lt 0\\
x/2 & for & x \geq 0
\end{array}\right.$
In this example, the domain of f is $\mathbb{R}$ (f is defined for all real numbers.)
Some function values:
$f(-1)=-2, \quad f(0)=0,\quad f(10)=5...$
(apply the rule for the interval to which x belongs to.)
$\text{Example 2.}$
Defining f with $f(x)=\left\{\begin{array}{lll}
-x & for & -5\lt x\lt 0\\
100& for & x=0 & \\
x+2 & for & x\gt 0
\end{array}\right.$
the domain of f is $(-5,+\infty)$
Some function values:
$f(-1)=+1, \quad f(0)=100,\quad f(10)=12...$
(apply the rule for the interval to which x belongs to.)