Lesson 1.5 · Functions
Piecewise functions
Real rules often change partway through. Tax brackets, shipping rates, a phone plan that charges extra after a data cap: each follows one formula up to some point and a different formula after it. A piecewise function captures that in a single function. In precalculus you'll also use piecewise definitions to rewrite absolute values, to build step functions, and to ask a question that leads straight into calculus: do the pieces connect?
Reading a piecewise definition
Definition
Piecewise function
A piecewise function uses different formulas on different parts of its domain. Each formula comes with a condition that says which inputs it applies to, and the conditions don't overlap.
For example,
To evaluate at an input, first decide which condition the input satisfies, then use only that formula.
Worked example: Evaluating and graphing
Find , , and for the function above, then graph it.
- , so use the first piece: .
- satisfies , so use the second piece: .
- also satisfies : .
- , so .
To graph, draw each formula only over its own interval. At each boundary, put a closed dot where the endpoint is included and an open dot where it isn't.
The first piece heads toward but doesn't include it, because . The value at belongs to the second piece, so the graph jumps up to the closed dot at .
Common mistake
Pay attention to versus at each boundary. A boundary input belongs to exactly one piece, and using the wrong piece there is the most common error with piecewise functions. Always check which condition includes the equal sign.
Do the pieces connect?
In the graph above, the pieces don't meet at or at : the graph has jumps there. When the pieces do meet, you can draw the graph without lifting your pencil at that boundary. Calculus calls that property continuity, and you'll study it carefully at the end of this course. For now, here is the practical test.
Joining pieces at a boundary
At a boundary , the graph of a piecewise function has no break when the formula on the left and the formula on the right give the same value at . To make the pieces connect, set the two formulas equal at and solve.
Worked example: Choosing a constant so the pieces connect
Find the value of that makes the graph of
have no break.
At the left piece gives and the right piece gives . Set them equal:
With both pieces reach the value at .
Absolute value as a piecewise function
The absolute value is secretly piecewise:
To rewrite an expression like , find where the inside is zero () and split there. This turns absolute value problems into ordinary algebra on each piece.
Worked example: Solving an equation with an absolute value
Write as a piecewise function, then solve .
For , , so .
For , , so .
Solve on each piece and keep only solutions that satisfy that piece's condition.
- gives . Since , it counts.
- gives . Since , it counts.
The solutions are and .
Step functions
A step function is piecewise constant: its graph looks like a staircase. The most important one is the greatest integer function (also called the floor function):
So , and . For negatives, "less than or equal to" means moving left on the number line, so rounds down to , not up to .
Step functions model charges that are rounded up to whole units: parking billed by the started hour, postage by the ounce, phone calls by the started minute.
Worked example: A parking garage
A garage charges $4 for the first hour or any part of it, plus $2.50 for each additional hour or part of an hour. How much does parking cost for 3 hours 12 minutes?
hours minutes is hours, which starts hours of billing: the first hour plus additional hours. The cost is
dollars. Parking for exactly hours would cost dollars, so the price jumps as soon as the fourth hour begins.
Practice
Let
Find .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
For the same function , find .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Find .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Find the value of so that the graph of this function has no break:
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Solve for
Enter all solutions, separated by commas.
Separate answers with commas, e.g. 2, -5
Which piecewise function is equal to ?
A parking lot charges $5 for the first hour or any part of it, plus $3 for each additional hour or part of an hour. How many dollars does it cost to park for 4.5 hours?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Which function has the graph shown?