When a rule changes depending on where x is, like a store that drops its price once you buy in bulk, we can use a piecewise function. A piecewise function groups two or more ordinary rules together in one curly bracket, with an if condition beside each rule that tells you where to use it.
1
Evaluating a Piecewise Function
First, we want to find the output of a piecewise function for specific inputs, such as f(5),f(0), and f(2) for
f(x)=⎩⎨⎧rule2x+1−x+4conditionif x<2if x≥2
Evaluating Piecewise Functions
Text solution
Plug in x=5 using the condition it matchesSince 5≥2, ignore the top rule and plug 5 into the bottom rule.
f(5)=−5+4=−1
Plug in x=0 using the condition it matchesSince 0<2, ignore the bottom rule and plug 0 into the top rule.
f(0)=2(0)+1=1
Check the border value x=2Only the bottom condition x≥2 has the "or equal to" bar underneath, so 2 goes into the bottom rule.
f(2)=−2+4=2
Even though the function is built from two formulas, each input x gives a single answer because only one condition is true at a time.
2
Graphing a Piecewise Function
Now we want to put that same two-piece function on a coordinate grid:
f(x)={2x+1−x+4if x<2if x≥2
Graphing a Piecewise Function
Text solution
Mark the border at x=2Draw a dashed vertical line where the rules switch at x=2.
x=2
Graph left of 2(x<2)Draw y=2x+1 only to the left of the border line, stopping at an open circle on the border because x<2 gets right up to 2 without including it.
y=2(2)+1=5⟶open circle at (2,5)
Graph right of 2(x≥2)Draw y=−x+4 from the border line to the right, starting with a solid dot on the border because x≥2 includes 2.
y=−2+4=2⟶solid dot at (2,2)
So at the border x=2, the graph jumps down from the open circle at (2,5) to the solid dot at (2,2).
For these two rules, the graph consists of two parts of lines, and the jump between the pieces disappears only when the border passes right through the point where the two lines cross.
Moving the border only changes where one line hands off to the other, and the jump disappears where the two lines cross.
3
Three-Piece and Step Functions
What if the rule changes twice, or the rules are just flat numbers with no x in them? We want to graph a function with three pieces,
f(x)=⎩⎨⎧−x+1x+1−2x+5if x<−1if −1≤x<2if x≥2
(where −1≤x<2 means x is between the borders −1 and 2, including −1 on the left but not 2 on the right), and a parking-cost function where x is the time parked in hours, 0<x≤3, and every rule is a constant number:
P(x)=⎩⎨⎧4812if 0<x≤1if 1<x≤2if 2<x≤3
Three-Piece and Step Functions
Text solution
Draw both border linesMark the two switching numbers with dashed vertical lines at x=−1 and x=2.
x=−1andx=2
Left of −1(x<−1)Graph y=−x+1 to the left of the first border, ending at an open circle because of the < symbol.
y=−(−1)+1=2⟶open circle at (−1,2)
Between −1 and 2(−1≤x<2)Keep only the middle piece of y=x+1 between the two borders, from a solid dot at x=−1 to an open circle at x=2.
yy=−1+1=0⟶solid dot at (−1,0)=2+1=3⟶open circle at (2,3)
Right of 2(x≥2)Graph y=−2x+5 to the right of the second border, starting at a solid dot because of the ≥ symbol.
y=−2(2)+5=1⟶solid dot at (2,1)
When the rules on the left are plain numbers with no x, each piece stays at a constant height between its borders:
step function (flat horizontal pieces)P(x)=⎩⎨⎧4812if 0<x≤1if 1<x≤2if 2<x≤3
4
Writing a Piecewise Function from a Graph
Now let's go backwards: given a two-piece graph, we want to write its curly-bracket equation.
x
y
−1
1
2
3
−4
−2
2
4
(0,3)
(1,4)
(1,−1)
(2,−3)
(3,−5)
Writing a Piecewise Function from a Graph
f(x)={??if ?if ?
Text solution
Find the border and conditions from the endpointsThe pieces stop and start at x=1, with a solid dot on the left piece (≤) and an open circle on the right piece (>).
if x≤1andif x>1
Left piece (x≤1)This line crosses the y-axis at (0,3) and goes up 1, right 1 to (1,4), so its slope is 1 and its y-intercept is 3.
y=1x+3=x+3
Right piece (x>1)From (1,−1) to (2,−3) the line goes down 2, right 1 (slope −2), and tracing backwards up 2, left 1 from (1,−1) reaches the y-axis at (0,1).
y=−2x+1
Putting both rules together with their conditions gives the complete function:
f(x)={x+3−2x+1if x≤1if x>1
5
Absolute Value as a Piecewise Function
How do absolute value functions fit in with piecewise functions? Let's see what y=∣x∣ does to the line y=x and write it as a two-piece function.
Absolute Value as a Piecewise Function
∣x∣=?
y=x
x
y
−2
2
−2
2
For x≥0, the absolute value bars leave y=x alone, while for x<0, they flip the negative outputs above the x-axis onto the line y=−x (where the minus sign turns negative inputs like x=−3 into −(−3)=+3). That gives two straight lines meeting at the border x=0:
∣x∣={x−xif x≥0if x<0
x
y
−3
3
2
4
y=xslope 1
y=−xslope −1
vertex
x=0
So the graph of y=∣x∣ consists of two rays that meet at a sharp corner called the vertex.
6
Graphing Absolute Value Functions
Instead of splitting an absolute value equation into two separate lines every time, we want to graph it directly from its vertex and the slopes of its arms:
y=2∣x−3∣+2andy=−21∣x+1∣+4
Graphing Absolute Value Functions
y=∣x−3∣vertex=?
y=∣x∣
x
y
−4
−2
2
4
2
4
Text solution
Find the vertex of y=2∣x−3∣+2Ask what value of x makes x−3 equal 0 inside the bars; when the bars equal 0, the +2 on the outside is the height y.
x−3y=0⟹x=3,=2(0)+2=2⟶vertex at (3,2)
Draw both arms using slopes 2 and −2From (3,2), go up 2, right 1 for the right arm and up 2, left 1 for the left arm.
right slopeleft slope=2,=−2⟶arms pass through(4,4) and (2,4)
Find the vertex and downward arms of y=−21∣x+1∣+4Plugging in x=−1 makes x+1 equal 0 and leaves height 4. The right arm has slope −21 and the left arm has slope 21, so from (−1,4), go down 1, right 2 for the right arm and down 1, left 2 for the left arm.
vertex at right slopeleft slope(−1,4),=−21,=21⟶arms pass through(1,3) and (−3,3)
Every number in the equation tells you one part of the V-graph directly:
y=slope of right arm2∣zero at x=3x−3∣+height y=22⟶vertex at (3,2)
In y=∣x−h∣+k, the sign inside the bars looks backwards because x=h has to cancel −h to make zero, while +k on the outside is just the vertex's height.
The vertex sits at the x-value that makes the inside of the bars equal 0, leaving the outside number as its height.
7
Writing Equations from an Absolute Value Graph
Now let's go from a V-shaped graph back to its equation, both with absolute value bars and as a two-piece function.
x
y
1
−2
2
(1,−3)
(0,0)
(2,0)
Writing Equations from an Absolute Value Graph
yf(x)=?={??if ?if ?
Text solution
Build the bars from the vertex (1,−3)Put x−1 inside the bars so that x=1 makes the inside zero, and put the vertex height −3 on the outside.
y=∣x−1∣−3
Find the slope of the right armFrom (1,−3) to (2,0) on the right arm, the graph goes up 3, right 1, so put +3 in front of the bars.
y=3∣x−1∣−3
Write the two-piece form using the vertex border x=1The left arm has slope −3 through (0,0), and tracing the right arm (slope 3) backwards down 3, left 1 from (1,−3) hits the y-axis at (0,−6).
f(x)={−3x3x−6if x<1if x≥1
Because the two arms meet at the corner (1,−3) with no jump, either condition can have the "or equal to" bar.
The number in front of the bars is the slope of the right arm (and the opposite of the left arm's slope, flipping the V upside down when it's negative), and the absolute value equation and two-piece equation are just two ways to write the same V-graph.
Tilt the V to see how the number in front of the bars gives the right arm's slope and the opposite slope on the left, while both equations keep describing the same two rays.
Key concepts
For the functions in this lesson, we work with parts of ordinary lines separated by vertical borders:
Evaluating a piecewise function
Check the if conditions on the right first and plug x into that single rule. Right on a border like x=2 in f(x)={2x+1−x+4if x<2if x≥2, only the rule with the ≤ or ≥ bar applies, giving f(2)=−2+4=2.
Graphing and reading piecewise lines
Draw a dashed vertical line at each border number, keep each line only on the side where its condition is true, and mark border endpoints with an open circle for < or > and a solid dot for ≤ or ≥ (if the rules are plain numbers like 4,8,12, the pieces are flat horizontal steps). When writing an equation from a graph, if a piece already crosses the y-axis, like a left piece passing through (0,3), read its y-intercept directly; only trace the slope backwards when the border cuts the piece off before it reaches the y-axis.
Absolute value graphs and equations
You don't need to split y=2∣x−3∣+2 into two separate lines just to graph it. Find the vertex (3,2) from the x-value that makes the inside of the bars zero (3−3=0) and the height left outside (+2), then use the number in front (2) as the right arm's slope and its opposite (−2) as the left arm's slope. From the vertex, both arms go up when the number in front is positive and down when it is negative. Only write the two individual line equations when asked for the curly-bracket piecewise form, using the vertex's x-coordinate as the border.
8
Practice
1
For f(x)={2x+5−3x+1if x<−1if x≥−1, find f(−3),f(2), and f(−1).
Before looking at the rules on the left, compare each input to the border number −1 on the right: which symbol includes −1 itself?
For x=−3, since −3<−1, use the top rule:
f(−3)=2(−3)+5=−1
For x=2, since 2≥−1, use the bottom rule:
f(2)=−3(2)+1=−5
For the border value x=−1, watch out for the mistake of plugging −1 into the top rule to get 2(−1)+5=3, or plugging it into both rules; because x<−1 is strictly less than −1 and only x≥−1 has the "or equal to" bar, −1 goes into the bottom rule:
f(−1)=−3(−1)+1=4
2
A dog wash charges a flat $5 for up to 10 minutes, $10 for more than 10 minutes up to 20 minutes, and $15 for more than 20 minutes up to 30 minutes. For 0<x≤30, write a step function C(x) for the cost of x minutes and describe the pieces of its graph.
Does the price climb every minute like 5x, or stay at a flat height across each 10-minute interval? Check whether "up to 10 minutes" puts the ≤ bar on the left or the right of each interval.
Each price is a flat constant, not 5x,10x, and 15x (which would make sloped lines charging $50 at 10 minutes instead of a flat $5). Also, "up to 10 minutes" includes 10, so put the ≤ bar on the right border of each interval rather than writing 10≤x<20 (which would charge $10 for exactly 10 minutes):
C(x)=⎩⎨⎧51015if 0<x≤10if 10<x≤20if 20<x≤30
Its graph has three horizontal segments: at y=5 from an open circle at (0,5) to a solid dot at (10,5), at y=10 from an open circle at (10,10) to a solid dot at (20,10), and at y=15 from an open circle at (20,15) to a solid dot at (30,15).
3
Graph the function below and give the coordinates and dot type at each border endpoint.
f(x)=⎩⎨⎧x+4−x+12x−2if x<−1if −1≤x<2if x≥2
Draw dashed vertical borders at x=−1 and x=2 first, then plug the border x-values into each piece's rule to find the exact height where that piece hits its border.
Draw dashed borders at x=−1 and x=2.
Left of x=−1, graph y=x+4 ending at an open circle at (−1,3).
Between x=−1 and x=2, graph y=−x+1. Don't stop this middle piece at x=1 and leave a gap between 1 and 2; even though x<2 doesn't include 2, the line continues all the way to the border at x=2, running from a solid dot at (−1,2) to an open circle at (2,−1).
Right of x=2, graph y=2x−2 starting at a solid dot at (2,2) with slope 2.
4
Write the piecewise function f(x) for a graph that splits at x=2: the left piece goes through (0,−1) and ends at a solid dot at (2,3), and the right piece starts at an open circle at (2,1) and goes through (3,−2) and (4,−5).
The left piece already crosses the y-axis, so you can read its y-intercept directly; for the right piece, find its slope first, then trace backwards from (2,1) all the way to x=0.
At the border x=2, the solid dot on the left gives x≤2 and the open circle on the right gives x>2.
The left piece crosses the y-axis at −1 and rises from (0,−1) to (2,3) with slope 2, giving 2x−1.
The right piece goes down 3, right 1 from (2,1) to (3,−2), so its slope is −3. Don't use the border height 1 from (2,1) as the y-intercept to write −3x+1, and don't stop after tracing back just one unit to (1,4); tracing up 3, left 1 twice from (2,1) to reach x=0 hits the y-axis at 7:
f(x)={2x−1−3x+7if x≤2if x>2
5
Graph y=3∣x+2∣−4 by finding its vertex and the slopes of its arms.
Don't read the +2 inside the bars as x=2, which puts the vertex at (2,−4) where the inside is ∣2+2∣=4 instead of 0.
What number can you plug in for x to make x+2 equal zero inside the bars?
Don't read the +2 inside the bars as x=2, which puts the vertex at (2,−4) where the inside is ∣2+2∣=4 instead of 0; the vertex is at (−2,−4) because x=−2 makes x+2=0 and leaves −4 outside.
From (−2,−4), draw the right arm going up 3, right 1 through (−1,−1) and (0,2), and the left arm going up 3, left 1 through (−3,−1) and (−4,2).
6
A V-shaped graph opens downward with its vertex at (3,4) and passes through (5,3) and (1,3). Write its absolute value equation.
Watch out for leaving off the minus sign on a downward-opening V (writing 21∣x−3∣+4) or putting run over rise to write −2∣x−3∣+4.
Build the inside of the bars so x=3 makes it zero, then count "down how many, right how many" from the vertex (3,4) to (5,3).
The vertex (3,4) gives ∣x−3∣ inside the bars and +4 outside.
From (3,4) to (5,3), the arm goes down 1 and right 2. Watch out for leaving off the minus sign on a downward-opening V (writing 21∣x−3∣+4) or putting run over rise to write −2∣x−3∣+4; going down 1, right 2 gives a slope of −21:
y=−21∣x−3∣+4
7
Write y=2∣x−3∣+1 as a piecewise function without absolute value bars.
First find the vertex to get the border where the two arms meet, then trace both the left arm (slope −2) and the right arm (slope 2) from the vertex back to the y-axis.
The vertex at (3,1) sets the border at x=3.
Don't just drop the bars and keep +1 as the y-intercept to write −2x+1 and 2x+1, or forget to flip the sign on −3 when distributing −2(x−3)+1 (which gives −2x−5). Tracing from the vertex (3,1) back 3 steps to the y-axis, the left arm of slope −2 goes up 2, left 1 three times to hit y=7, and the right arm of slope 2 goes down 2, left 1 three times to hit y=−5: