A piecewise-defined function uses different formulas on different parts of its domain. These functions appear throughout calculus as examples and counterexamples, especially in discussions of continuity and differentiability where the behavior at the boundary between pieces is the key question.
| Example | Description |
|---|---|
| \lfloor x \rfloor$ | Floor (greatest integer) function |
What Is a Piecewise-Defined Function?
A piecewise-defined function is a function whose formula changes depending on which part of the domain the input belongs to. The general form is:
f(x) = \begin{cases} \text{formula 1} & \text{if } x \in \text{region 1} \\ \text{formula 2} & \text{if } x \in \text{region 2} \\ \vdots & \vdots \end{cases}You have already seen the most famous example: the absolute value function
|x| = \begin{cases} x & \text{if } x \ge 0 \\ -x & \text{if } x < 0 \end{cases}The Floor Function
The floor function (also called the greatest integer function) assigns to each real number $x$ the largest integer that is less than or equal to $x$. It is denoted $\lfloor x \rfloor$.
For example:
- $\lfloor 2.7 \rfloor = 2\lfloor 3 \rfloor = 3\lfloor -1.2 \rfloor = -2-1$, because $-2 \le -1.2$ while $-1 > -1.2\lfloor 0.9 \rfloor = 0$
The graph of $y = \lfloor x \rfloor$ is a staircase: it is constant on each interval $[n, n+1)$ for integer $n$, with a jump discontinuity at each integer. This makes it a standard example for studying discontinuities in calculus.
Evaluating Piecewise Functions
To evaluate a piecewise function at a given input, first determine which piece's condition the input satisfies, then apply that piece's formula.
Let $f(x) = \begin{cases} x^2 + 1 & \text{if } x < 0 \\ 2x - 1 & \text{if } x \ge 0 \end{cases}$. Find $f(-3)$, $f(0)f(4)$.
Solution
- $f(-3)$: Since $-3 < 0$, use the first piece: $f(-3) = (-3)^2 + 1 = 9 + 1 = 10f(0)$: Since $0 \ge 0$, use the second piece: $f(0) = 2(0) - 1 = -1f(4)$: Since $4 \ge 0$, use the second piece: $f(4) = 2(4) - 1 = 7$.
Continuity at the Boundary
One of the most common questions about a piecewise function is whether it is continuous at the boundary point where the formula changes. A piecewise function is continuous at the boundary $x = c$ when the two pieces agree at that point (give the same value). If they disagree, there is a jump discontinuity.
In the example above, the two pieces give $f(0) = 0^2 + 1 = 1$ (from the left piece) and $f(0) = 2(0)-1 = -1$ (from the right piece). Since $1 \ne -1$, the function is discontinuous at $x = 0$.