Some functions use different formulas for different parts of their domain. These are called piecewise-defined functions. The absolute value, signum, and floor functions are classic examples that appear throughout mathematics, engineering, and computer science.
Quick Reference
| Function | Formula | Key property |
|---|---|---|
| Absolute value | $ \lvert x \rvert=\left\{\begin{aligned} &x &&\text{if }x \geq 0\\ &-x &&\text{if }x < 0 \end{aligned}\right.$ | Always nonnegative; V-shaped graph |
| Signum | $\operatorname{sgn}(x) =\left\{\begin{aligned} &1 &&\text{if }x > 0\\ &0 &&\text{if } x=0 \\&-1 &&\text{if }x < 0 \end{aligned}\right.$ | Extracts the sign of $x$ |
| Floor / Greatest integer | $\lfloor x \rfloor$ = largest integer $\leq x$ | Rounds down to nearest integer |
Piecewise-Defined Functions
A piecewise-defined function is one that uses different formulas for different subsets of its domain.
For example, the function g: ℝ → ℝ defined by
$ g(x)=\left\{ \begin{aligned} 3x+1 &&\text{if }x< -2\\ x^2-4 &&\text{if }x\geq -2 \end{aligned} \right. $is a piecewise-defined function.
The Absolute Value Function
The absolute value function $f(x) = |x|$ is defined by
$f(x) = \begin{cases} x & \text{if } x \geq 0 \\ -x & \text{if } x < 0. \end{cases}$The absolute value gives the distance of $x$ from zero on the number line. Its graph is V-shaped with vertex at the origin.

The Signum (Sign) Function
The signum function (or sign function), denoted $\operatorname{sgn}$, is defined by
$\operatorname{sgn}(x) = \begin{cases} 1 & \text{if } x > 0 \\ 0 & \text{if } x = 0 \\ -1 & \text{if } x < 0. \end{cases}$The signum function extracts the sign of a real number: positive inputs give $+1$, negative inputs give $-1$, and zero gives $0$.

The Greatest Integer (Floor) Function
The greatest integer function (or floor function), denoted $\lfloor x \rfloor$, is the largest integer less than or equal to $x$. In other words, it rounds $x$ down to the nearest integer:
$\lfloor x \rfloor = \max\{m \in \mathbb{Z} \mid m \leq x\}.$Examples:
$\lfloor 7 \rfloor = 7, \quad \lfloor 1.34 \rfloor = 1, \quad \lfloor 3.99 \rfloor = 3, \quad \lfloor \sqrt{2} \rfloor = 1, \quad \lfloor 0.12 \rfloor = 0,$$\lfloor -7 \rfloor = -7, \quad \lfloor -1.34 \rfloor = -2, \quad \lfloor -3.99 \rfloor = -4, \quad \lfloor -\sqrt{2} \rfloor = -2.$Note that for negative numbers, rounding down means rounding away from zero.
- The floor function maps $\mathbb{R} \to \mathbb{Z}$ (all integers).
- Other notations: $[x]$ and $[\![x]\!]$.

Evaluating and Graphing Piecewise Functions
A function $f$ is defined by
$f(x) = \begin{cases} 2x - 3 & \text{if } x > 2 \\ x - 1 & \text{if } -1 < x \leq 2 \\ -2x + 1 & \text{if } x \leq -1. \end{cases}$Evaluate $f(2)$, $f(0)$, $f(-1)$, and plot the graph.
Solution
Since $2 \in (-1, 2]$, use the middle formula: $f(2) = 2 - 1 = 1.$ Since $0 \in (-1, 2]$, use the middle formula: $f(0) = 0 - 1 = -1.$ Since $-1 \in (-\infty, -1]$, use the bottom formula: $f(-1) = -2(-1) + 1 = 2 + 1 = 3.$