What Is A Piecewise Function?
A piecewise function is a single function defined by different sub-rules on different parts of its domain. Each sub-rule comes with a condition that says which inputs it governs, and the pieces are collected under one brace:
$$f(x) = \begin{cases} x^2 & \text{if } x \le 1 \ 2x - 1 & \text{if } x > 1 \end{cases}$$
Read it as an instruction: if the input is $1$ or smaller, apply $x^2$; if the input is larger than $1$, apply $2x - 1$. The value $x = 1$ where the rule changes is called a breakpoint (or boundary point). Everything difficult about piecewise functions happens at the breakpoints, so the conditions there have to be read exactly, including whether the boundary uses $\le$ or $<$.
The idea sits inside the broader family of types of functions: a piecewise function is not a new kind of object, it is an ordinary function whose formula simply changes from region to region. Many familiar functions are secretly piecewise, including the absolute value and every step function.
How Do You Evaluate A Piecewise Function?
To evaluate a piecewise function, find the single condition the input satisfies, then substitute into that rule and no other. Using the wrong piece at the boundary is the most common error, so check the condition before you compute.
Take a three-rule example:
$$g(x) = \begin{cases} -x & \text{if } x < 0 \ x^2 & \text{if } 0 \le x \le 2 \ 5 & \text{if } x > 2 \end{cases}$$
Example 1: Evaluate $g(-3)$, $g(0)$, $g(2)$, and $g(4)$.
$$g(-3): ; -3 < 0 \implies g(-3) = -(-3) = 3$$
$$g(0): ; 0 \le 0 \le 2 \implies g(0) = 0^2 = 0$$
$$g(2): ; 0 \le 2 \le 2 \implies g(2) = 2^2 = 4$$
$$g(4): ; 4 > 2 \implies g(4) = 5$$
Final answer: $g(-3) = 3$, $g(0) = 0$, $g(2) = 4$, $g(4) = 5$.
The only judgement call is at $x = 0$ and $x = 2$. Because the middle rule owns both endpoints ($0 \le x \le 2$), the squares win there, not the neighbouring pieces.
How Do You Graph A Piecewise Function?
To graph a piecewise function, draw each rule only over the interval its condition allows, then mark the endpoints. A filled (closed) dot means the endpoint is included ($\le$ or $\ge$); an open (hollow) dot means it is excluded ($<$ or $>$).
Consider a function built to jump:
$$h(x) = \begin{cases} x + 1 & \text{if } x < 1 \ x^2 & \text{if } x \ge 1 \end{cases}$$
Draw $y = x + 1$ for every $x$ up to $1$. As $x$ approaches $1$ from the left, the height approaches $1 + 1 = 2$, but $x = 1$ is excluded, so place an open dot at $(1, 2)$.
Draw $y = x^2$ from $x = 1$ onward. At $x = 1$ the height is $1^2 = 1$, and $x = 1$ is included, so place a closed dot at $(1, 1)$.
The graph lifts from height $1$ to height $2$ at the boundary, a jump discontinuity. Geometrically, you cannot draw $h$ through $x = 1$ without lifting your pen, which is the visual signature of a break.
Is A Piecewise Function Continuous At A Breakpoint?
A piecewise function is continuous at a breakpoint $x = c$ when three things hold at once:
$f(c)$ is defined (the piece that owns $c$ produces a value).
The two-sided limit exists, which for a breakpoint means the left and right limits agree: $\lim_{x \to c^-} f(x) = \lim_{x \to c^+} f(x)$.
That common limit equals the function value: $\lim_{x \to c} f(x) = f(c)$.
Geometrically, all three together say the graph arrives at the same height from both sides and actually lands there, so no pen-lift is needed.
Example 2: Check continuity of $f$ at the breakpoint $x = 1$, where $f(x) = \begin{cases} x^2 & x \le 1 \ 2x - 1 & x > 1 \end{cases}$
$$f(1) = 1^2 = 1 \quad (\text{the } x \le 1 \text{ piece owns } x = 1)$$
$$\lim_{x \to 1^-} f(x) = \lim_{x \to 1^-} x^2 = 1$$
$$\lim_{x \to 1^+} f(x) = \lim_{x \to 1^+} (2x - 1) = 2(1) - 1 = 1$$
All three values equal $1$, so $f$ is continuous at $x = 1$. Compare this with $h$ from the graphing section, where the left limit was $2$ and the value was $1$: unequal, so $h$ fails condition 3 and is discontinuous. For the wider picture of where this breaks, see discontinuous functions.
Is A Piecewise Function Differentiable At A Breakpoint?
Continuity is necessary but not sufficient for differentiability. A piecewise function is differentiable at a breakpoint $x = c$ when it is continuous there and the one-sided derivatives match:
$$\lim_{x \to c^-} f'(x) = \lim_{x \to c^+} f'(x)$$
Geometrically, the derivative is the slope of the tangent line, so this condition says both pieces arrive at the join with the same slope, leaving one smooth tangent instead of a corner. A single well-defined tangent means the graph is smooth through the breakpoint. The derivative itself is the tool doing the checking.
Example 3: Is the same $f$ differentiable at $x = 1$?
Differentiate each piece:
$$f'(x) = \begin{cases} 2x & x < 1 \ 2 & x > 1 \end{cases}$$
$$\text{Left slope: } \lim_{x \to 1^-} 2x = 2 \qquad \text{Right slope: } \lim_{x \to 1^+} 2 = 2$$
The slopes agree at $2$, and we already showed $f$ is continuous at $x = 1$, so $f$ is differentiable there with $f'(1) = 2$. This function is both continuous and smooth at its breakpoint.
Example 4: The absolute value function is continuous but not differentiable at $0$.
Written piecewise, the absolute value function is:
$$|x| = \begin{cases} -x & \text{if } x < 0 \ x & \text{if } x \ge 0 \end{cases}$$
Continuity at $0$: the left limit is $\lim_{x \to 0^-}(-x) = 0$, the right limit is $\lim_{x \to 0^+} x = 0$, and $|0| = 0$, so all three agree and $|x|$ is continuous at $0$.
Differentiability at $0$: differentiate each piece and read the one-sided slopes.
$$\frac{d}{dx}(-x) = -1 \qquad \frac{d}{dx}(x) = +1$$
$$\text{Left slope } = -1 \neq +1 = \text{right slope}$$
The slopes disagree, so $|x|$ is not differentiable at $0$. The graph makes a sharp corner (a V) there, and a corner has no single tangent line. This is the standard proof that continuity does not imply differentiability.
Table: Reading the breakpoint of a piecewise function.
At the breakpoint $x = c$ | Left = right limit = $f(c)$? | One-sided slopes equal? | Result |
|---|---|---|---|
Jump (like $h$ above) | No | Not applicable | Discontinuous |
Corner (like $\lvert x\rvert$) | Yes | No | Continuous, not differentiable |
Smooth join (like $f$ above) | Yes | Yes | Continuous and differentiable |
What Are Absolute Value And Step Functions As Piecewise Functions?
Two of the most-used functions in a first calculus course are piecewise underneath.
Absolute value, $|x|$, is the two-piece function above. It is the model example of a continuous function with a corner, and it appears wherever a distance or a magnitude is needed.
The Heaviside step function turns something on at a threshold:
$$H(x) = \begin{cases} 0 & \text{if } x < 0 \ 1 & \text{if } x \ge 0 \end{cases}$$
$H$ jumps from $0$ to $1$ at the origin, so it is discontinuous at $0$. It models a switch flicking on, a force applied at an instant, or a signal starting.
The greatest integer (floor) function, $\lfloor x \rfloor$, rounds down to the nearest integer and is a whole staircase of pieces, one flat step on each unit interval, jumping at every integer. It is covered in full at greatest integer function and floor and ceiling function. A close relative, the signum function, reports only the sign of its input as $-1$, $0$, or $+1$.
Why Do The Continuity And Differentiability Tests Work?
The two breakpoint tests are not arbitrary rituals. Each measures whether a specific kind of gap exists at the join.
The continuity test asks whether the two pieces reach the same height at the boundary. If the left piece climbs toward one value and the right piece starts at another, there is literally a vertical gap in the graph, and no amount of algebra hides it.
The differentiability test asks whether the two pieces arrive at the same slope. Even when the heights match, the pieces can meet at an angle, and an angle has no single tangent direction. The derivative from the left and the derivative from the right are then two different numbers, so the derivative at the corner does not exist.
This is why order matters: you check continuity first, because a broken graph cannot possibly be smooth. Differentiability is the stricter demand, height-agreement plus slope-agreement, which is exactly why a continuous corner like $|x|$ still fails it. Continuity buys you an unbroken curve; differentiability then buys you a smooth one on top of that.
Who Shaped The Idea Of Piecewise Functions?
For a long time a "function" meant a single formula, and anything defined by parts looked like a mathematical cheat. That prejudice was overturned in the nineteenth century.
Two more figures shaped the tools this article uses:
Augustin-Louis Cauchy (1789–1857, France) defined continuity through limits, giving the exact three-part test that decides what happens at a breakpoint.
Oliver Heaviside (1850–1925, England) put the step function to work in physics and electrical engineering, making the humble two-piece switch one of the most-applied piecewise functions in science.
Where Are Piecewise Functions Used In The Real World?
Piecewise rules appear wherever behaviour changes past a threshold.
Taxation and economics: progressive income tax applies one marginal rate up to a limit and a higher rate above it. The tax owed is continuous at each threshold but has a corner, so it is a real-world case of continuous-yet-not-differentiable.
Shipping and utilities: postage that costs one price up to a weight and jumps at the next tier is a step function, discontinuous at each boundary.
Physics and engineering: a force switched on at an instant, or a circuit powered up, is modelled with the Heaviside step; control systems are full of such switches.
Computer graphics and machine learning: the ReLU activation $\max(0, x)$ used across neural networks is exactly the piecewise function that is $0$ for negative inputs and $x$ otherwise, and it has a corner at $0$ just like $|x|$.
Everyday pricing: phone plans, parking rates, and bulk discounts all switch rules at set thresholds.
One structure, a rule that changes at a boundary, runs tax codes, shipping tables, circuits, and the activations inside modern machine learning.
What Are The Most Common Mistakes With Piecewise Functions?
These three errors account for most lost marks, confirmed against VarsityTutors' continuity-and-piecewise lesson, the NumberAnalytics guide on piecewise continuity, and the Grokipedia entry on piecewise functions, and they match the questions students actually ask.
Using the wrong piece at the boundary.
Where it slips in:
At a breakpoint, a student grabs the neighbouring rule instead of the one whose condition actually contains the point, misreading $\le$ as $<$.
Don't do this:
Do not guess which piece owns the endpoint. The inequality decides it, and only one piece may claim any given input.
The correct way:
Read the condition first. For $g$ above, $x = 2$ satisfies $0 \le x \le 2$, so use $x^2$ to get $g(2) = 4$, not the $x > 2$ rule.
Confusing "defined in pieces" with "continuous."
Where it slips in:
A student assumes that because the function has a formula everywhere, its graph must connect at the breakpoints.
Don't do this:
Do not skip the limit check. A piecewise-defined function is often discontinuous, exactly where the pieces reach different heights.
The correct way:
Test all three conditions at each breakpoint: left limit, right limit, and $f(c)$ must be equal. If they are not, the function jumps there.
Assuming continuity implies differentiability.
Where it slips in:
Having shown a function is continuous at a breakpoint, a student concludes the derivative exists there too.
Don't do this:
Do not stop at continuity. A continuous graph can still have a corner, and a corner has no derivative.
The correct way:
After continuity passes, compare the one-sided derivatives. For $|x|$ at $0$ they are $-1$ and $+1$, so despite being continuous the function is not differentiable there.
Practice Problems On Piecewise Functions
Answers follow each problem.
For $f(x) = \begin{cases} x^2 + 1 & x < 0 \ 2x & x \ge 0 \end{cases}$, find $f(-2)$ and $f(3)$.
(Answer: $f(-2) = (-2)^2 + 1 = 5$; $f(3) = 2(3) = 6$.)Is the function in Problem 1 continuous at $x = 0$?
(Answer: left limit $= 0^2 + 1 = 1$, right limit $= 2(0) = 0$, $f(0) = 0$; since $1 \neq 0$ it is discontinuous, a jump of size $1$.)Find $a$ so that $f(x) = \begin{cases} ax + 1 & x \le 2 \ x^2 + 3 & x > 2 \end{cases}$ is continuous at $x = 2$.
(Answer: left value $= 2a + 1$, right limit $= 2^2 + 3 = 7$; set $2a + 1 = 7$, so $a = 3$.)Is $f(x) = \begin{cases} x^2 & x \le 1 \ 2x - 1 & x > 1 \end{cases}$ differentiable at $x = 1$?
(Answer: yes; it is continuous there and the one-sided slopes are $2x\big|_{1} = 2$ and $2$, which match, so $f'(1) = 2$.)Evaluate the floor function at $\lfloor 2.7 \rfloor$ and $\lfloor -1.3 \rfloor$.
(Answer: $\lfloor 2.7 \rfloor = 2$; $\lfloor -1.3 \rfloor = -2$, since floor rounds down.)A two-bracket tax charges $10\%$ on income up to $10{,}000$ and $12\%$ on the amount above. Write the tax $T(x)$ as a piecewise function and state whether it is continuous at $10{,}000$.(Answer: $T(x) = \begin{cases} 0.10x & 0 \le x \le 10000 \ 1000 + 0.12(x - 10000) & x > 10000 \end{cases}$; at $x = 10000$ both pieces give $1000$, so it is continuous, though the slopes $0.10$ and $0.12$ differ, giving a corner.)
Where Should You Go Next After Piecewise Functions?
Piecewise functions sit right where algebra meets calculus, and several natural doors open from here.
Discontinuous functions. Classify the breaks a piecewise function can have, jump, removable, and infinite discontinuities.
Absolute value function. The cleanest example of a continuous function with a corner, studied on its own.
Greatest integer function. A full staircase of pieces, the model step function for practising breakpoints.
If your child is meeting continuity and differentiability for the first time, a live Bhanzu trainer builds piecewise functions from the graph up, so the breakpoint tests come from seeing the corner rather than memorising a rule, in the Bhanzu math tutoring program.
Was this article helpful?
Your feedback helps us write better content
