Some functions are defined in pieces by different formulas in different parts of their domains. We saw two of such functions in Example 1 of the previous section. We call such functions piecewise-defined functions.
Absolute Value Function
An important example of a piecewise defined function is the absolute value function $f(x)=|x|$, which can also be written as:
\[
f(x)=\left\{\begin{matrix}
x & \text{if } x\geq 0\\
-x & \text{if } x<0
\end{matrix}\right.
\]
The graph of this function is shown in Fig 1.
Sign Function
Another important piecewise defined function is the sign (or signum) function. The sign function, often denoted by ${\rm sgn}$ or $\text{sign}$, extracts the sign of a real number $x$ (see Fig 2.)
\[
{\rm sgn}(x)=\left\{ \begin{matrix}
1 & \text{if } x>0\\
0 & \text{if } x=0\\
-1 & \text{if } x<0
\end{matrix}\right.
\]
Greatest Integer Function or Floor Function
A function that takes a real number $x$ as input and returns the largest integer less than or equal to $x$ is called the greatest integer function or the floor function. It is denoted $\lfloor x\rfloor$. In fact, this function rounds down a real number to the nearest integer. For example
\[
\lfloor7\rfloor=7,\qquad\lfloor 1.34\rfloor=1,\qquad\lfloor 3.99\rfloor=3,
\]
\[
\lfloor-7\rfloor=-7,\qquad\lfloor-1.34\rfloor=-2,\qquad\lfloor-3.99 \rfloor=-4,
\]
\[\lfloor\sqrt{2}\rfloor=1,\qquad\lfloor0.12\rfloor=0\]
\[\lfloor-\sqrt{2}\rfloor=-2,\qquad\lfloor-0.12\rfloor=-1\]
- The greatest integer function is a function from $\mathbb{R}$ to $\mathbb{Z}$ (set of all integers)
\[
\mathbb{R}\to\mathbb{Z}
\] - Using mathematical notations, we can write
\[
\lfloor x\rfloor=\max\{m\in\mathbb{Z}|\ m\leq x\}.
\] - Other symbols for the greatest integer function are $[x]$ and $[\![x]\!]$.
The graph of $y=\lfloor x\rfloor$ is shown in Figure 3.