Piecewise Functions
Learning goals
- Partition the domain so exactly one piece owns each input
- Evaluate by choosing the piece whose condition holds
- Graph each piece over its own interval only
- Mark a closed or open dot at each boundary
- Compare the two heights to tell a jump from a join
- Build the range from each piece's restricted outputs
What a piecewise function is
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. For example,
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.
Why each input must belong to exactly one piece#
A function is a rule that assigns to every input in its domain exactly one output. A piecewise definition can only be a genuine function when its conditions do two things. Those conditions must never assign one input to two conflicting pieces, and they must never leave an intended input with no piece at all.
Suppose some input satisfied two conditions whose formulas disagree, giving one piece the value and another the value with . Then the rule would offer two different outputs at the same input, and a rule that returns two values is not a function. So the conditions must never overlap in a way that hands a single input two different results. The safe design, and the one used everywhere, is to make the conditions mutually exclusive, so no input satisfies more than one.
Now suppose instead that some input we intend to feed in satisfied no condition at all. Then the rule would give it no output, and the function would simply be undefined there. So the conditions must also cover every input in the intended domain. Putting the two requirements together, the conditions must partition the domain: each input lands in one piece and only one.
This is the whole reason for the careful inequality signs at a boundary. Where two pieces meet at a value , exactly one of them must claim . Writing one condition as and the next as hands to the first piece and to no other. Writing them as and would be an error, because then satisfies both and the function risks two values. Writing them as and would be an error too, because then satisfies neither and the function has a gap.
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 “the graph runs up to here, but this point belongs to the other piece.”
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: do the two pieces reach the same height there? 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 hole, 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.
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 the three functions you studied just before it 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.
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. The charge rises smoothly with no sudden leap at one mile. That matches the design, since the extra-mile rate only starts adding once you pass the first mile.