Piecewise Functions
Progress can't be saved in this browser, so this lesson's status can't be set.
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, as in above. A larger piecewise function works the same way with more pieces. Here is one with three:
Read the conditions first, then use the matching formula. For , only holds, so . For , the middle condition holds, so . Substituting into another formula would give the wrong output.
A boundary is an input where one interval ends and the next begins, such as or here. At a boundary, check which inequality includes the “or equal to” part. The input fails but satisfies , so it uses the middle piece: . Throughout this lesson, the conditions give each input in the intended domain exactly one piece. This avoids conflicting outputs. Overlapping conditions can still define a function if their formulas agree wherever they overlap.
For example, suppose is used for and for . Both conditions claim , where the outputs and differ, so this rule is not a function. If the second formula were instead, both would give at , and that overlap would be harmless.
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 answer 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 . What is new is deciding what to draw at the ends of each interval, and the inequality signs tell you how.
For the line and polynomial pieces here, substitute the boundary input to locate the endpoint. Use a closed dot if the condition includes that input ( or ), and an open dot if it excludes it ( or ). A filled dot belongs to the graph; a hollow dot only shows where that piece approaches. Another piece may include the same point.
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.
For , the boundary formulas give and . The two heights differ, so there is a jump at . Do not draw a vertical segment between them: that would assign several outputs to the same input.
For adjacent line, constant, or polynomial pieces, compare their values at the boundary. Each piece approaches the value its formula gives there. If the heights agree and one piece includes that point, the graph connects. If the heights differ, it jumps. This test is enough for the pieces used here.
The conditions still matter. If both pieces exclude the boundary, even matching heights leave a point missing. Also, if a different kind of formula is undefined at the boundary, you cannot use substitution to decide how its graph behaves there. Do not assume that every boundary is a jump or a join.
Compare with a function whose pieces agree at the boundary:
At the first piece heads toward and the second piece sits at . 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 is the set of inputs covered by the conditions where the selected formulas are defined. The formulas here are defined on their entire listed intervals, so combine those intervals. This combination is their union. For , together with covers all real numbers.
Conditions need not cover every real number. The parking model accepts only ; zero and negative stays are outside its intended domain. Within that domain, each input must have exactly one output.
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 has three separate parts. 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.
Absolute value, floor, and ceiling as piecewise functions
Three familiar functions can now be read as piecewise rules. Start with 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 is why the V of the absolute value graph connects at its vertex instead of jumping. There is no gap, just a 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 integer 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 both step functions.
The ceiling has the same step shape, built from its own pieces. It holds the constant value on the interval , with the opposite endpoint pattern to a floor step: 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 describe rules that change at thresholds, such as the pricing rules below. 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. A tax model can apply different rates to different bands of income. 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.