Piecewise & Absolute Value Functions
Ever noticed how a ride-share app charges one rate for the first few kilometres, then a different rate after that? The rule changes depending on how far you travel. That is exactly what a piecewise function does — and it is one of the most useful tools in applied mathematics.
Practise this lesson
Three printable worksheets that build from foundations to mastery — or build your own from any module’s questions.
A delivery app charges $5 for any trip under 3 km, then adds $1.50 for every kilometre beyond 3 km. How much would a 2 km trip cost? How much would a 5 km trip cost? Why can't we describe both trips with a single simple formula like $C = 5 + 1.5d$?
Piecewise
Key insight: The absolute value of a negative number is positive because the negative sign flips the sign. For example, $|-7| = -(-7) = 7$.
Key facts
- The definition of a piecewise function
- The piecewise definition of absolute value
- How to evaluate piecewise functions at given inputs
Concepts
- Why real-world pricing models often need piecewise rules
- Why $|x|$ is always non-negative
- How the graph of a piecewise function can change direction at a boundary point
Skills
- Evaluate piecewise functions for numerical inputs
- Write and interpret piecewise rules in context
- Solve basic absolute value equations
- Sketch piecewise linear functions
A piecewise function is a function defined by different rules for different parts of its domain. Instead of one formula that works everywhere, we use multiple formulas, each with its own condition.
For example:
$$f(x) = \begin{cases} 2x + 1 & \text{if } x < 3 \\ 10 - x & \text{if } x \geq 3 \end{cases}$$
To evaluate this function, first check which condition the input satisfies, then apply the matching rule.
How to evaluate a piecewise function
- Look at the input value.
- Find the condition that matches the input.
- Apply only that rule.
- Simplify.
For the function above:
- $f(2)$: since $2 < 3$, use $2x + 1 \Rightarrow f(2) = 2(2) + 1 = 5$
- $f(3)$: since $3 \geq 3$, use $10 - x \Rightarrow f(3) = 10 - 3 = 7$
- $f(5)$: since $5 \geq 3$, use $10 - x \Rightarrow f(5) = 10 - 5 = 5$
Misconceptions to fix
Wrong: (a + b)² = a² + b².
Right: (a + b)² = a² + 2ab + b²; the middle term 2ab is essential and commonly forgotten.
A piecewise function uses different rules for different parts of the domain; Always check the condition before choosing which rule to apply
Pause — copy the piecewise definition (different rules for different parts of the domain) and the two-step evaluation procedure (check the condition first, then apply the matching rule) into your book.
Did you get this? True or false: for the piecewise function $f(x) = \begin{cases} 2x+1 & x < 3 \\ 10-x & x \geq 3 \end{cases}$, we evaluate $f(3)$ using the rule $2x + 1$.
Quick check: For $f(x) = \begin{cases} x^2+1 & x \leq 2 \\ 5x-3 & x > 2 \end{cases}$, what is $f(2)$?
We just saw that a piecewise function uses a different rule depending on which part of the domain the input falls into. That raises a question: is there a common function that already has a built-in two-piece rule baked into its definition? This card answers it → the absolute value function $|x|$ is itself piecewise: $x$ when $x \geq 0$, and $-x$ when $x < 0$.
The absolute value of a number is its distance from zero on the number line. Distance is always non-negative, so absolute value always produces a positive result or zero.
We can define absolute value as a piecewise function:
$$|x| = \begin{cases} x & \text{if } x \geq 0 \\ -x & \text{if } x < 0 \end{cases}$$
This definition explains why $|-7| = 7$: because $-7 < 0$, we use the second piece and get $-(-7) = 7$.
Solving absolute value equations
If $|A| = B$ where $B \geq 0$, then there are two possibilities:
- $A = B$
- $A = -B$
For example, to solve $|2x - 4| = 6$:
- Case 1: $2x - 4 = 6 \Rightarrow 2x = 10 \Rightarrow x = 5$
- Case 2: $2x - 4 = -6 \Rightarrow 2x = -2 \Rightarrow x = -1$
Both solutions should be checked in the original equation.
$|x|$ = distance from zero; always $\geq 0$; $|x| = x$ if $x \geq 0$; $|x| = -x$ if $x < 0$
Pause — copy the absolute value piecewise definition ($|x| = x$ if $x \geq 0$; $|x| = -x$ if $x < 0$) and the distance-from-zero interpretation into your book.
Fill the blanks: drag each token into the matching blank.
The absolute value of a ___ number is ___ because $-x$ means the ___ of $x$. An absolute value equation $|A| = B$ always has ___ cases to solve.
Worked examples · reveal as you go
Evaluate $f(-1)$, $f(2)$, and $f(4)$ for $\displaystyle f(x) = \begin{cases} x^2 + 1 & \text{if } x \leq 2 \\ 5x - 3 & \text{if } x > 2 \end{cases}$
Solve $|3x - 6| = 9$.
A courier company charges $\$5$ for deliveries up to and including $2$ km, and $\$5$ plus $\$1.50$ for each kilometre beyond $2$ km for longer deliveries. Write a piecewise function $C(d)$ for the cost in dollars of a delivery of $d$ km.
Common mistakes · the 4 traps that cost marks
Using the wrong piece at the boundary
At the boundary value, always check whether the condition includes $\leq$, $\geq$, $<$, or $>$. If the condition says $x \leq 3$, then $x = 3$ belongs to that piece. If it says $x < 3$, then $x = 3$ does not.
✓ Fix: Before substituting, write the condition next to the input and tick the one that matches.
Thinking $|x|$ is always positive, so $|x| = x$ for all $x$
Many students incorrectly write $|-5| = -5$ because they forget the piecewise definition. The negative piece $|x| = -x$ is what turns negative inputs into positive outputs.
✓ Fix: Always ask: is the expression inside the absolute value positive or negative? If negative, multiply it by $-1$.
Forgetting the second case in absolute value equations
Equations like $|2x - 1| = 7$ almost always have two solutions. Students frequently stop after finding the first one.
✓ Fix: Every time you see $|A| = B$, immediately write $A = B$ and $A = -B$ side by side.
Writing the extra-distance piece incorrectly in context problems
In a ride-share problem, students sometimes write $1.5d$ for the entire trip when only the distance beyond the threshold should be charged at the higher or lower rate.
✓ Fix: Use $d - \text{threshold}$ for the variable part, not $d$ itself. The fixed fee covers the first part of the trip.
Activity 1 — Evaluate the piecewise function
Consider the function $\displaystyle f(x) = \begin{cases} 2x + 3 & \text{if } x < 1 \\ x^2 & \text{if } 1 \leq x \leq 3 \\ 12 - x & \text{if } x > 3 \end{cases}$
Find $f(0)$.
Find $f(1)$.
Find $f(3)$.
Find $f(5)$.
Quick check: For the piecewise function above, which rule is used to evaluate $f(3)$?
Quick-fire practice · 5 reps +2 XP per reveal
For $f(x) = \begin{cases} 3x-1 & x < 2 \\ x^2-1 & x \geq 2 \end{cases}$, find $f(0)$.
Evaluate $|-8|$.
Solve $|x - 2| = 5$.
A shop charges $\$20$ flat for orders under $\$100$, and $\$20$ plus $5\%$ of the amount over $\$100$ for larger orders. What is $C(150)$?
Why does $|x|$ always give a non-negative result?
Earlier you were asked: A delivery app charges $5 for any trip under 3 km, then adds $1.50 for every kilometre beyond 3 km. How much would a 2 km trip cost? How much would a 5 km trip cost? Why can't we describe both trips with a single simple formula?
A 2 km trip costs $5 because it falls under the flat-rate condition ($d < 3$). A 5 km trip costs $5 + 1.50(5-3) = \$8$ because it exceeds the threshold. A single simple formula like $C = 5 + 1.5d$ would charge $5 + 1.5(2) = \$8$ for the 2 km trip, which is wrong. The rule genuinely changes at the 3 km boundary, so a piecewise function is required to model the pricing accurately.
Pick your answer, then rate your confidence — that tells the system what to drill next.
Q1. Consider $\displaystyle f(x) = \begin{cases} 3x - 1 & \text{if } x < 2 \\ 5 & \text{if } x = 2 \\ x^2 - 1 & \text{if } x > 2 \end{cases}$. Find $f(0)$, $f(2)$, and $f(3)$. Show which piece you used for each. (3 marks)
Q2. A theme park charges $\$40$ for entry if you are under 16 years old, and $\$60$ if you are 16 or older. Let $A(x)$ be the admission cost in dollars for a person of age $x$. (a) Write $A(x)$ as a piecewise function. (b) Find $A(15)$ and $A(16)$. (c) Explain why a single linear formula cannot model this pricing structure. (4 marks)
Q3. A student solves $|2x - 4| = 8$ and writes: "$2x - 4 = 8$, so $x = 6$." Evaluate whether this answer is complete. If it is not, find the missing solution and explain why it must be included. (3 marks)
Comprehensive answers (click to reveal)
Multiple choice — drill bank
MC answers and feedback are shown inline as you complete each question. Use the retry button to attempt a fresh set.
1. B — $x = 2$ satisfies $x \leq 2$, so $f(2) = 3(2) + 1 = 7$.
2. B — $|-5| = 5$.
3. A — $|x| = x$ if $x \geq 0$, and $-x$ if $x < 0$.
4. B — $4 \geq 3$, so $f(4) = 2(4) + 1 = 9$.
5. B — $y = |x - 2|$ has vertex at $(2, 0)$.
Activity 1 — Evaluate the piecewise function model answers
1. $f(0) = 2(0) + 3 = 3$ (first piece, since $0 < 1$)
2. $f(1) = (1)^2 = 1$ (second piece, since $1 \leq 1 \leq 3$)
3. $f(3) = (3)^2 = 9$ (second piece, since $1 \leq 3 \leq 3$)
4. $f(5) = 12 - 5 = 7$ (third piece, since $5 > 3$)
Short answer model answers
Q1 (3 marks): $f(0) = 3(0) - 1 = -1$ using $3x - 1$ because $0 < 2$ [1]. $f(2) = 5$ using the middle piece because $x = 2$ [1]. $f(3) = (3)^2 - 1 = 8$ using $x^2 - 1$ because $3 > 2$ [1].
Q2 (4 marks):
(a) $A(x) = \begin{cases} 40 & \text{if } x < 16 \\ 60 & \text{if } x \geq 16 \end{cases}$ [1]
(b) $A(15) = \$40$ and $A(16) = \$60$ [1].
(c) A single linear formula would produce a gradual increase in cost as age increases, but the actual pricing jumps from $\$40$ to $\$60$ at exactly age 16 [1]. A piecewise function is needed because the rate of change is not constant across all ages [1].
Q3 (3 marks): The student's answer is incomplete [1]. They missed the second case: $2x - 4 = -8 \Rightarrow 2x = -4 \Rightarrow x = -2$ [1]. The missing solution must be included because absolute value represents distance from zero, so there are two values of $x$ that give an expression inside the absolute value with magnitude 8 [1].
Five timed questions on piecewise and absolute value functions. Beat the boss to bank a tier — gold (perfect + fast), silver (80%+), or bronze (cleared).
⚔ Enter the arenaClimb platforms, hit checkpoints, and answer piecewise function questions. Quick recall, lighter than the boss.
Mark lesson as complete
Tick when you've finished the practice and review.