Piecewise Functions
Learning goals
- Evaluate a piecewise function by choosing the piece whose condition holds
- Graph each piece over its own interval with a closed or open dot at the boundary
- Compare the two boundary heights to tell a jump from a join
- Find the domain and range from each piece's restricted interval
- Recognize absolute value, floor, and ceiling as piecewise functions from earlier lessons
What a piecewise function is
Take the parking garage from the introduction: dollars for a stay of one hour or less, dollars for anything longer. Call the charge for a stay of hours. There are two rules, and each one owns its own share of the possible stays:
Every value of is in dollars. To use it, decide which condition your stay satisfies, then read off that piece’s charge.
| Stay | Condition true | Charge |
|---|---|---|
| hour | ||
| hour | ||
| hours |
A piecewise function is defined by two or more formulas, called pieces, each paired with a condition that says which inputs it governs. The pieces are collected under one large brace, exactly as is above. A larger piecewise function works the same way with more pieces. Here is one with three:
Read the brace as a short list of instructions. Given an input , run down the conditions on the right, find the single one that satisfies, and apply the matching formula on the left. Nothing about the notation is mysterious; it is just a compact way to say “the value is whichever of these lines applies to your input.”
To evaluate a piecewise function at a number, always decide the condition first and compute second. Take . Scanning the conditions, is not less than , and it does not lie between and . But is greater than , so the third piece owns it and . Take instead. It satisfies , the middle condition, so . Choosing the formula before substituting is the entire skill. Plugging into the first or third piece would produce a number the function never actually returns at .
The care is needed at a boundary, an input where one condition ends and the next begins. Look at . The first condition asks for , which fails, and the second asks for , which passes thanks to the “or equal to.” So the boundary belongs to the middle piece alone, and . The inequality signs are not decoration. The strict on one side and the on the other are exactly what hand the shared point to a single piece. Those two signs also keep the other piece from claiming that point.
Worked example 1 Evaluate a three-piece function
Use the function
and find , , , and . For each input, name the condition first.
The input satisfies , so the first piece applies and .
The input is a boundary. It fails but satisfies , so the middle piece owns it and .
The input is the other boundary. It satisfies (again by the “or equal to”), so the middle piece applies and .
The input satisfies , so the third piece applies and .
Both boundaries went to the middle piece, because both of its inequalities carry the “or equal to.”
Check your understanding
Find for the function
Check the conditions at . The boundary fails but satisfies because of the 'or equal to', so the second piece owns it.
The tempting comes from the first piece , which applies only for and does not include the boundary.
Graphing a piecewise function
To graph a piecewise function, graph each piece on its own interval and nowhere else. For the running , you draw the line only to the left of , and the parabola only from to . The line is drawn only to the right of . The one new question a piecewise graph raises is what to draw at the ends of each interval, and the inequality signs answer it.
At a boundary the piece that includes the endpoint (its condition uses or ) genuinely reaches that point. Because that piece reaches the point, you mark its end with a closed dot, a filled circle. The piece that excludes the endpoint (its condition uses or ) approaches the point but never arrives. Because that piece never arrives, you mark its end with an open dot, a hollow circle. A filled dot says “this exact point is on the graph.” A hollow dot says “this piece stops just short of here, so its own boundary input is decided by another condition instead.”
Watch how that plays out on a simple two-piece function:
The first piece is the line drawn up to . Its condition includes the boundary (), so it truly reaches the point , drawn as a closed dot. The second piece is the constant drawn for every input past . Its condition excludes the boundary (), so at it stops just short with an open dot at . Between those two dots the graph leaps straight from height up to height without passing through the values in between. That leap is a jump.
Whether a piecewise graph jumps or connects at a boundary comes down to one comparison, as long as both pieces actually settle on a definite height there: do the two pieces reach the same height? Plug the boundary into both formulas and see. For , the left piece gives while the right piece gives . The heights differ, so the graph cannot be drawn without lifting the pen, and a jump appears. When the two pieces land on the same height instead, the closed dot and the open dot fall on the very same point. That shared point fills the gap, and the graph connects into an unbroken curve. No limits or calculus are needed for this; you simply evaluate both pieces at the boundary and compare the two numbers, provided both pieces actually have a number to give there.
That last condition is not automatic. Every piece in this lesson is a line, a constant, or a polynomial, and each of those has a definite value at every input, so the plug-in test above always applies here. It would not work for every possible piece. The last lesson’s rational functions can fail to have a height at a boundary in two different ways: a hole, where the formula is simply undefined at that one input, or a vertical asymptote, where the height runs off without settling on any number as the input gets close. Either way there is no finite height to plug in, so the jump-or-connect comparison above does not apply, and deciding what happens there takes the separate tools the last lesson built for exactly that purpose.
Compare with a function whose pieces agree at the boundary:
At the first piece heads toward and the second piece sits at . Same height. The excluded point from the left piece and the included point from the right piece are both . Because they are the same point, they merge into one filled dot and the graph has no gap. It still turns a sharp corner, because the slopes differ ( on the left, on the right), but a corner is not a jump. You can trace the whole graph without lifting the pen.
Worked example 2 Describe the graph at each boundary
Sketch the shape of
reading off the dots and deciding jump or connect at each boundary.
At , the left piece is the constant , which excludes (its condition is ), so it gives an open dot at . The middle piece includes and gives , a closed dot at . Both pieces reach height , so the dots land on the same point and the graph connects at .
At , the middle piece includes and gives , a closed dot at . The right piece is the constant , which excludes (its condition is ), so it gives an open dot at . The heights and differ, so the graph jumps at .
So runs flat at height , then rises along a line of slope from up to the closed dot . From there the graph leaps up to the open dot and stays flat at height .
Check your understanding
At the boundary , describe the graph of
The first piece includes the boundary (), so it reaches with a closed dot, since . The second piece excludes the boundary (), so at it gives an open dot at .
The two heights differ, against , so the graph jumps rather than connects.
Domain and range
The domain of a piecewise function is the set of inputs it accepts, and it is the union of the intervals attached to the pieces. When the conditions partition the domain, as they should, those intervals fit together with no overlap and no gap. Because those intervals fit together that way, you can read the domain straight off the conditions. For , the conditions and together account for every real number, so the domain of is all real numbers.
The range is the set of outputs, and you build it one piece at a time. Find the values each piece produces over its own interval, then take the union. A piece is only responsible for the part of its graph that actually gets drawn, so restrict each formula to its interval before reading off its outputs. For , the line on produces every height up to and including (reached at the boundary ). The constant piece contributes only the single height . The range of is therefore together with , with everything strictly between and skipped over by the jump.
Worked example 3 Find the domain and range
Work out the domain and range of
For the domain, list the intervals: , then , then . Together they cover every real number with no overlap, so the domain is all real numbers.
For the range, take the pieces one at a time. The first piece is the constant , contributing only the value . The middle piece runs over the closed interval , so its outputs run from up to , giving every height in . The third piece is the constant , contributing only the value . Union the three:
The range is not a single interval. It is a stack of separate pieces. The heights between and , and between and , are never reached, because the two jumps skip straight over them.
Check your understanding
Find the range of the function
Take the pieces one at a time. The line on climbs up to and including its value at the boundary.
The constant piece adds only the single height . Together the range is or ; the heights strictly between and are skipped by the jump.
The special functions were piecewise all along
This lesson is a capstone for the chapter, because three functions you studied earlier in this chapter were piecewise the whole time. The clearest case is the absolute value. Its rule keeps a nonnegative input as is and flips the sign of a negative input, which is precisely a two-piece definition:
At the boundary the top piece gives and the bottom piece heads toward as well, so the two pieces meet at the same height. That agreement is exactly why the V of the absolute value graph connects at its vertex instead of jumping. Same height at the boundary means no gap, just the sharp corner where the slopes switch from to .
Worked example 4 Write an absolute value as a piecewise function
Rewrite without the bars, as a piecewise function.
The bars keep their contents when the inside is zero or positive and negate the contents when the inside is negative, so split on the sign of . The inside is nonnegative when , that is , and negative when :
Tidy the lower piece by distributing the sign, , so the function reads for and for . Check the boundary: at the top piece gives and the bottom formula also heads toward . The two pieces therefore meet, so the graph is the usual V with its corner at .
The floor and ceiling are piecewise too, only with infinitely many pieces. The floor holds the constant value on each interval . So writing one line per integer gives a piecewise definition with a separate constant piece for every whole-number step. Unlike the absolute value, neighboring floor pieces reach different heights at each integer boundary, one unit apart, so the floor jumps by one at every integer. That is why its graph is a staircase of separate steps rather than a connected curve. A piecewise function with constant pieces like this, whose graph is a row of flat segments, is called a step function. The floor and ceiling are the headline examples.
The ceiling has the same step shape, built from its own pieces. It holds the constant value on the interval , the mirror image of the floor’s interval: instead of owning its left endpoint, each ceiling piece owns its right endpoint. That is why the ceiling’s steps land one row higher than the floor’s on most of each interval, and why the two functions agree only exactly at the integers.
Check your understanding
Why is the floor function a piecewise function?
The floor keeps a constant value on each interval , a separate piece for every integer, so it has infinitely many pieces rather than two. Unlike the absolute value, neighboring floor pieces reach different heights at each integer boundary, so the graph jumps by one every time instead of connecting.
Check your understanding
The floor holds its constant value on , owning its left endpoint. On which interval does the ceiling hold the constant value ?
The ceiling rounds up, so it must already equal the instant passes and keep that value all the way through itself. That is the interval : the ceiling owns its right endpoint, the mirror of the floor owning its left endpoint.
Piecewise models in the real world
Piecewise functions are the natural language for any rule that changes at thresholds, which is most real pricing. Postage climbs in jumps as a package crosses weight limits. A parking garage bills one amount for the first hour and another after that. A phone plan charges a flat monthly fee up to some data cap, then a per-gigabyte rate beyond it. Income tax applies one rate to the first band of income and steeper rates to higher bands. In every case a single function describes the cost, and its formula depends on which band the input falls into.
Worked example 5 A shipping cost that jumps
A store sets its shipping charge by the order weight , in pounds:
Every value is in dollars. Find the charge on orders weighing exactly pounds, pounds, and pounds, and describe the graph.
An order of exactly pounds sits on a boundary. The first condition includes because of the “or equal to,” so the first tier owns it and the charge is dollars. An order of pounds satisfies , so it costs dollars. An order of pounds satisfies , so it costs dollars.
Because each tier is a constant, the graph is flat within a tier and jumps up at each boundary, exactly a step function like the floor. The boundary weights and each belong to the lower tier, which is why a package right at the limit still ships at the cheaper price. Reading the inequality the other way, so that pounds cost dollars, would overcharge every order that lands exactly on a limit.
Worked example 6 Build a piecewise fare from a description
A taxi charges a flat dollars for any trip up to and including one mile, then dollars for each mile beyond the first. Write the fare as a function of the distance in miles (with ), and find and .
Up to one mile the fare is the flat charge, dollars, so the first piece is the constant on . Past one mile, you still pay the dollars plus dollars for each of the extra miles, so the second piece is on :
Evaluate. A one-mile trip is on the boundary, which the first piece includes, so dollars. A four-mile trip uses the second piece, dollars.
Check the boundary for a jump. At the first piece gives , and the second formula heads toward as well, the same height, so this fare connects with no sudden leap at one mile. The graph still turns a corner there, since the rate changes from flat to rising, but a corner is not a jump. That matches the design, since the extra-mile rate only starts adding once you pass the first mile.