Piecewise Functions
How to choose the correct rule, draw open and closed endpoints, find ranges and solve equations for piecewise functions.
Choose the rule from the input interval
A piecewise function uses different rules on different parts of its domain. Check which interval the input lies in before calculating the output. At a boundary value such as x=2, use the rule whose interval includes it: x\le2 includes 2, but x<2 does not.
Worked example 1
The function f is defined by
f(x)=\begin{cases}x+3 & -3\le x<0 \\ 4 & 0\le x<2 \\ 6-x & 2\le x\le5\end{cases}
Find f(-1), f(0) and f(2).
- -1 belongs to the first interval, so f(-1)=-1+3=2
-
Your turn. What is f(0)? Use the rule whose interval includes 0.
Zero belongs to 0\le x<2, so f(0)=4
- Two belongs to the last interval, so f(2)=6-2=4
- Answer: f(-1)=2, f(0)=4, f(2)=4
Explore which piece is active
An open circle marks a point that is not part of the graph; a filled circle marks one that is. Where one piece stops at an open circle and the next starts at a filled circle in the same place, as at (2,4), the graph simply carries on through that point: draw it filled.
Worked example 2
The function f is defined by
f(x)=\begin{cases}x+3 & -3\le x<0 \\ 4 & 0\le x<2 \\ 6-x & 2\le x\le5\end{cases}
Draw the graph of f, marking its endpoints correctly.
- The first segment goes from filled (-3,0) to open (0,3). The second is horizontal at height 4, starting with filled (0,4)
- The second piece stops short of x=2, so it ends with an open circle at (2,4). The last rule starts at x=2 with the same height, 6-2=4, so the point (2,4) is drawn filled and the graph is joined there. From (2,4) the last piece slopes down to x=5
-
Your turn. Calculate the final height, 6-5
The final endpoint is filled (5,1)
- Answer: the three separate segments described above. Do not join (0,3) to (0,4) with a vertical line: that would assign several outputs to one input.
Worked example 3
The function f is defined by
f(x)=\begin{cases}x+3 & -3\le x<0 \\ 4 & 0\le x<2 \\ 6-x & 2\le x\le5\end{cases}
State the domain and range of f.
- The input intervals together cover every value from -3 to 5, including both endpoints.
- The first piece produces 0\le f(x)<3. The middle piece gives 4. The last produces every output from 1 to 4, inclusive.
-
Your turn. What is the greatest output of the whole function?
The greatest output is 4
- Answer: domain -3\le x\le5; range 0\le f(x)\le4. There are no gaps in the combined set of outputs.
Solve on each piece, then check the interval
Solving a piece's formula can give a value of x outside the interval where that formula applies, and such a value is not a solution. Solve each piece that could give the required output, keep only the values of x that lie in that piece's own interval, and list the ones that remain.
Worked example 4
The function f is defined by
f(x)=\begin{cases}x+3 & -3\le x<0 \\ 4 & 0\le x<2 \\ 6-x & 2\le x\le5\end{cases}
Solve f(x)=2.
- First piece: x+3=2 gives x=-1, which is in -3\le x<0. The constant middle piece has output 4, so gives no solution.
-
Your turn. Solve 6-x=2 on 2\le x\le5
x=4, which lies in the last interval.
- Answer: x=-1 or x=4. The horizontal line y=2 meets the graph twice.
Worked example 5
The function h is defined by
h(x)=\begin{cases}2x+1 & x<3 \\ k-x & x\ge3\end{cases}
Find k so the two pieces meet without a jump.
-
Your turn. What value does 2x+1 give when x=3? The left-hand piece never reaches x=3, but it gets as close as you like to this height.
2(3)+1=7
- The right-hand piece does include x=3, where its value is k-3. For the two pieces to meet with no jump, this must equal 7: k-3=7
- Answer: k=10. Both formulas then give the height 7 at x=3, so the graph is joined there.
Worked example 6
The function g is defined by
g(x)=\begin{cases}x^2+1 & -2\le x<1 \\ 5-x & 1\le x\le4\end{cases}
Solve g(x)=3.
- The quadratic piece gives x^2+1=3, so x=\pm\sqrt2. But \sqrt2>1, outside that piece.
-
Your turn. Which quadratic root lies in -2\le x<1?
Keep x=-\sqrt2
- The linear piece gives 5-x=3, so x=2, which is in its interval.
- Answer: x=-\sqrt2 or x=2. Each solution must pass its own interval check.
Common mistakes
- Choosing a rule from the output. Use the input’s interval to choose the rule.
- Filling an excluded endpoint. Use an open circle for a strict boundary such as x<2.
- Joining a jump with a vertical line. Leave the gap; a vertical join would give one input several outputs.
- Leaving overlapping range pieces uncombined. Combine the outputs from every piece into one set.
- Keeping a solution outside its piece. Check each candidate against the interval of the rule used.
Now try it: Piecewise Functions practice questions
More on this topic: Piecewise Functions worksheet with full solutions