Piecewise Functions: Graphs, Limits, Continuity and Derivatives
Piecewise functions explained: how to read and graph them, find one-sided limits, check continuity and differentiability, and integrate across pieces.
Special and piecewise functions Updated 3 min read
At a glance
- Domain
- The union of the intervals the pieces cover
- Continuous at x = a
- When \lim_{x\to a^-}f_1(x) = \lim_{x\to a^+}f_2(x) = f(a)
- Derivative
- f'(x) = \begin{cases} f_1'(x) & x < a \\ f_2'(x) & x > a \end{cases}
- Integral
- \int_b^c f(x)\,dx = \int_b^a f_1(x)\,dx + \int_a^c f_2(x)\,dx
- Examples
- Absolute value, floor function, tax brackets, shipping rates
On this page
A piecewise function is a function defined by different formulas on different parts of its domain. The rule tells you which formula to use based on where x is. Piecewise functions are the standard test cases for limits, continuity and differentiability, because the interesting behavior happens where the pieces meet.
How to read a piecewise function
To evaluate, first find which condition x satisfies, then use that piece only. Here f(0) = 0^2 = 0, f(1) = 3 - 1 = 2 (because x \ge 1 includes 1), and f(2) = 3 - 2 = 1.
Graph of a piecewise function
Each piece is drawn only on its own interval. An open dot marks an endpoint that is not included; a closed dot marks one that is.
Limits of piecewise functions
At a break point a, compute the two one-sided limits separately, each with its own piece. For the function above at a = 1:
The one-sided limits differ, so \lim_{x\to 1}f(x) does not exist, and the graph has a jump. Away from the break point, a limit is just direct substitution into the active piece.
Continuity at a break point
f is continuous at a when all three of these agree:
- the left-hand limit \lim_{x\to a^-}f(x),
- the right-hand limit \lim_{x\to a^+}f(x),
- the value f(a).
Example: choosing a constant. For which k is
continuous? The left limit at 2 is 2k + 1 and the right limit and value are 2^2 = 4. Setting 2k + 1 = 4 gives k = \frac{3}{2}.
Derivatives of piecewise functions
Inside each open interval, differentiate the active piece as usual. At a break point you need two checks:
- f must be continuous there (a jump means no derivative).
- The left and right derivatives must match: \lim_{h\to 0^-}\frac{f(a+h) - f(a)}{h} = \lim_{h\to 0^+}\frac{f(a+h) - f(a)}{h}.
When both pieces are differentiable polynomials and f is continuous at a, the second check reduces to comparing f_1'(a) with f_2'(a).
Example: a corner. The absolute value function |x| is -x for x < 0 and x for x \ge 0. It is continuous at 0, but the left slope is -1 and the right slope is 1, so |x| is not differentiable at 0.
Example: continuous but not smooth. For g above with k = \frac{3}{2}, the left slope at 2 is \frac{3}{2} and the right slope is 2x = 4. They differ, so g is continuous but not differentiable at x = 2.
Integrating a piecewise function
Split the integral at every break point inside the interval. For the first function on [0, 3]:
The second integral is \left[3x - \frac{x^2}{2}\right]_1^3 = \frac{9}{2} - \frac{5}{2} = 2. A single jump does not change the value of the integral, so it does not matter which piece owns the point x = 1.
Common mistakes
- Using the wrong piece at the boundary. Check whether the condition says < or \le before evaluating f(a).
- Concluding continuity from one side. Both one-sided limits and the value must agree.
- Assuming continuous means differentiable. Corners like |x| at 0 are continuous but have no derivative.
- Differentiating the pieces and comparing them at a jump. If f is not continuous at a, it is not differentiable there, even if the piece slopes happen to match.
- Integrating one formula across the whole interval. Always split at the break points.
Related functions
The floor and ceiling functions are piecewise constant step functions with a jump at every integer, and absolute value is the simplest piecewise function with a corner. For the full treatment of limits and continuity, see the guide to continuity.
Practice it now
Continuity
Solve real problems on this topic with instant feedback, hints and a step-by-step walkthrough for every answer. Free, no sign-up needed to start.
Practice this lesson