How to Differentiate a Piecewise Function
At a glance
- 1. Differentiate each piece
Apply the usual derivative rules separately on each interval where the formula is fixed.
- 2. Find the breakpoints
Check every point where the defining formula or interval changes.
- 3. Test continuity
At each breakpoint, compare the function value with the left- and right-hand limits.
- 4. Compare slopes
If the function is continuous, compare the one-sided derivatives; they must agree for a derivative to exist.
A piecewise function can have a different formula on each part of its domain. To differentiate it, first differentiate each formula where that formula applies. Then check the points where the formula changes: a piecewise function may have a derivative everywhere inside its intervals but fail to be differentiable at a breakpoint.
The key test is local. At a breakpoint, the function must be continuous, and the slopes approaching from the left and right must agree. If either requirement fails, there is no derivative at that point.
Differentiate inside each interval
Suppose a function is defined by
For points strictly less than , differentiate . For points strictly greater than , differentiate . These ordinary derivative rules apply on each interval independently. The breakpoint needs its own check; it is not automatically covered by either formula for the derivative.
For instance, if for and for , the derivatives away from are and , respectively. This gives the derivative on the two open intervals, but does not yet determine whether exists.
Check differentiability at a breakpoint
The derivative at is defined by the difference quotient
if this limit exists. A two-sided limit exists only if the corresponding one-sided limits both exist and are equal.
A practical test is:
- Find using the piece that includes .
- Check whether the left- and right-hand limits of at equal . This is continuity at .
- Find the left-hand and right-hand limits of the difference quotient, or compute the one-sided derivatives using the adjacent formulas.
- Conclude that exists only if both one-sided derivatives are finite and equal.
Continuity is necessary but not sufficient. A graph can meet at a point and still have a corner there, giving different one-sided slopes. Conversely, if a function is discontinuous at , it cannot be differentiable there.
Worked example: a matching join
Consider
For , . For , . Now check the join. The function value is . The left-hand limit is , and the right-hand limit is , so the function is continuous.
The one-sided slopes are
They agree, so . The full derivative can therefore be written as
The choice of which interval includes in this derivative notation is just a way to state the value there; the derivative at was established by checking both sides.
Worked example: a corner
For , write the function as
The function is continuous at , since both pieces approach . But the derivative from the left is , while the derivative from the right is . Since these slopes differ, does not exist. Away from , its derivative is for and for .
A jump gives another reason a derivative can fail to exist. For example, if the left and right formulas approach different values at a breakpoint, the function is discontinuous there, so there is no derivative at that point.
Common mistakes
- Only differentiating the formulas: This finds the derivative away from the breakpoints, not necessarily at them.
- Checking only continuity: A continuous join can still have a corner, as does at .
- Comparing formula values instead of limits: At a breakpoint, use the value assigned by the definition for , and separately check the limits from both sides.
- Assuming a piecewise derivative automatically includes the breakpoint: A displayed derivative formula at is valid only after the derivative has been shown to exist there.
- Ignoring domain endpoints: If is an endpoint of the function’s domain, the usual two-sided derivative is not defined there. Some contexts define a one-sided derivative instead, so state which convention is being used.
For a piecewise function with several pieces, repeat the breakpoint test at every point where the formula changes. A derivative can exist at some joins and fail at others.
References
- Calculus: Early Transcendentals — James Stewart, Daniel Clegg, and Saleem Watson
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.