Sometimes a single equation isn't enough because the math rule changes depending on the number we plug in.
1
What a Piecewise Function Is and How to Evaluate It
A piecewise function uses different rules in different x-zones, separated by a border. Here is a function whose rule changes at the border x=1, and we want to find f(3),f(−2), and f(1):
f(x)=⎩⎨⎧rulex+22x−3if zonex<1if x≥1
What a Piecewise Function Is and How to Evaluate It
Text solution
Right of the border (x=3)Since 3≥1, the input 3 belongs to the bottom zone, so we ignore the top rule and plug 3 into the bottom rule.
f(3)=2(3)−3=6−3=3
Left of the border (x=−2)Since −2<1, the input −2 falls in the top zone, so we plug it into the top rule.
f(−2)=−2+2=0
On the border (x=1)The bottom inequality has the "or equal to" bar (x≥1), which means the border value 1 belongs to the bottom rule.
f(1)=2(1)−3=2−3=−1
2
Writing a Piecewise Function from a Word Problem
Now let's build the curly-bracket equation ourselves from a real-life cutoff: a t-shirt shop charges $15 per shirt for up to 10 shirts and $10 per shirt for more than 10 shirts, and we want to write the cost function C(x) for x shirts and find the cost of 8,10, and 11 shirts.
Writing a Piecewise Function from a Word Problem
Text solution
Up to the border (0<x≤10)Buying 10 or fewer shirts costs $15 per shirt, and the ≤ bar includes the border of 10 shirts in this first zone.
C(x)=15xif 0<x≤10
Past the border (x>10)Buying more than 10 shirts drops the price to $10 per shirt, which gives the second row of our piecewise function.
C(x)={15x10xif 0<x≤10if x>10
Evaluate at 8,10, and 11 shirtsBoth 8 and the border value 10 fall in 0<x≤10, while 11 falls in x>10, making 11 shirts cheaper than 8.
Next, we want to draw the graph of our first piecewise function by finding where each line meets the vertical border at x=1:
f(x)={x+22x−3if x<1if x≥1
Graphing a Piecewise Function
Text solution
Left endpoint on the border (x=1)Plug the border x=1 into the left rule x+2 to see where that line stops, and mark it with an open circle because x<1 comes right up to 1 without touching it.
1+2=3⟹open circle at (1,3)
Draw the left ray (x<1)Because we are drawing to the left of the border, use the slope of 1 from (1,3) by going down 1 and left 1.
(1,3)down 1, left 1(0,2)down 1, left 1(−1,1)
Right endpoint and ray (x≥1)Plug x=1 into the right rule 2x−3 for a closed dot (since x≥1 includes the border), then follow the slope of 2 up 2 and right 1.
2(1)−3=−1⟹closed dot at (1,−1)up 2, right 1(2,1)up 2, right 1(3,3)
At the vertical border x=1, we keep only the left part of y=x+2 (ending in an open circle) and the right part of y=2x−3 (starting at a closed dot), so every x-value has a single output.
Moving the border doesn't move the two lines, only where they get trimmed and which dot counts on the border.
4
Graphing a Step Function
What if the rules inside a piecewise function have no x in them and are just flat numbers? A piecewise function made of constant rules is a step function, because each piece has slope 0 and graphs as a flat horizontal segment. Here is the cost of a parking garage that charges a flat $5 for up to 1 hour, $10 for more than 1 hour up to 2 hours, and $15 for more than 2 hours up to 3 hours:
f(x)=⎩⎨⎧51015if 0<x≤1if 1<x≤2if 2<x≤3
Graphing a Step Function
Text solution
First step (0<x≤1)Draw a flat segment at height 5 from an open circle at x=0 (since 0<x) to a closed dot at x=1 (since x≤1).
open circle at (0,5)⟶closed dot at (1,5)
Second step (1<x≤2)Past 1 hour, jump up to height 10 from an open circle at x=1 to a closed dot at x=2.
open circle at (1,10)⟶closed dot at (2,10)
Third step (2<x≤3)Past 2 hours, jump up to height 15 from an open circle at x=2 to a closed dot at x=3.
open circle at (2,15)⟶closed dot at (3,15)
5
Writing a Piecewise Equation from a Graph
Now let's go in reverse: we are given a piecewise graph and want to write its curly-bracket equation.
Each piece is part of a straight line y=mx+b, where m is the rise-over-run slope between two points and b is the y-intercept where the line crosses the y-axis (x=0).
Writing a Piecewise Equation from a Graph
f(x)={??if ?if ?
Text solution
Read the border and zonesBoth endpoints line up vertically at x=2, with a closed dot on the left piece and an open circle on the right piece.
left zone: x≤2,right zone: x>2
Find the left line (x≤2)From (0,3) to (2,1) the line goes down 2 and right 2, and it crosses the y-axis directly at (0,3).
m=2−2=−1,b=3⟹y=−x+3
Trace the right line back to the y-axis (x>2)From (2,4) to (3,6) the slope is 2 (up 2, right 1), so we extend that line from (2,4) by going left 1 and down 2 until we hit x=0.
(2,4)left 1, down 2(1,2)left 1, down 2(0,0)⟹b=0,y=2x
Combine the piecesPair each line's rule with its zone.
f(x)={−x+32xif x≤2if x>2
6
Absolute Value as a Piecewise Function and How to Graph It
What happens when two pieces don't jump apart at the border, but meet at the exact same point to form a sharp corner? The parent absolute value function f(x)=∣x∣ is a piecewise function with a border at x=0: it leaves positive numbers alone (y=x) and multiplies negative numbers by −1 to make them positive (y=−x):
the corner (vertex) sits at the border where the inside of the bars equals zero. Let's use the vertex and the slope a in front to graph y=∣x−3∣+2,y=2∣x−3∣+2, and y=−2∣x−3∣+2.
Absolute Value as a Piecewise Function and How to Graph It
Text solution
Set the inside to zero for the vertexThe inside expression x−3 equals zero when x=3, which leaves the outside number 2 as the y-value of the vertex.
x−3y=0⟹x=3,=2∣3−3∣+2=2⟹vertex at (3,2)
Step out with positive a(y=2∣x−3∣+2)With a=2, go up 2 and over 1 in both directions from the vertex (3,2) so the V stays symmetric.
(3,2)(3,2)up 2, right 1(4,4),up 2, left 1(2,4)
Step out with negative a(y=−2∣x−3∣+2)A negative number in front flips the V upside down, so from (3,2) go down 2 and over 1 in both directions.
(3,2)(3,2)down 2, right 1(4,0),down 2, left 1(2,0)
For nonzero a in the family y=a∣x−3∣+2, the vertex stays fixed on the border at (3,2) while the number a in front sets the slope of the right branch (and −a on the left branch), flipping the V upside down whenever a is negative. When a=0, the graph is the horizontal line y=2.
The number in front of the absolute value bars sets the slope of the right branch from the vertex, while the left branch mirrors it across the line of symmetry.
7
Writing an Absolute Value Equation from a Graph
Because an absolute value equation only needs the vertex and the number a in front of the bars, we can read both straight from a V-shaped graph.
Writing an Absolute Value Equation from a Graph
yy=a∣x−h∣+k=?
Text solution
Put the vertex (−1,4) into the barsWrite the expression inside the bars that equals zero when x=−1, and put the vertex's y-value +4 outside the bars.
−1+1=0⟹∣x+1∣+4
Count the slope a on the right branchFrom the vertex (−1,4) to (0,1) on the right branch, we go down 3 and right 1, which gives the number to put in front of the bars.
a=1−3=−3⟹y=−3∣x+1∣+4
8
Rewriting an Absolute Value Function as a Piecewise Function
Finally, what if we have an absolute value equation like
f(x)=∣2x−6∣+1
and want to rewrite it as a curly-bracket piecewise function with no absolute value bars?
Rewriting an Absolute Value Function as a Piecewise Function
f(x)f(x)=∣2x−6∣+1={??if ?if ?
Text solution
Set the inside to zero for the borderThe absolute value bars change what they do right where the inside expression equals zero.
2x−6=0⟹2x=6⟹x=3
Drop the bars on the positive side (x≥3)When x≥3, the inside 2x−6 is zero or positive, so the bars do nothing and we simply remove them.
(2x−6)+1=2x−5
Flip the inside on the negative side (x<3)When x<3, the inside 2x−6 is negative, so we replace the bars with parentheses and a minus sign in front of only the inside expression.
−(2x−6)+1=−2x+6+1=−2x+7
Write the piecewise functionPair each simplified line with its zone (since the two branches meet at the vertex, the "or equal to" bar can go on either zone, though we usually write x≥3).
f(x)={2x−5−2x+7if x≥3if x<3
For f(x)=∣2x−6∣+1, the border x=3 splits the function into y=−(2x−6)+1=−2x+7 on the left (where 2x−6 is negative) and y=2x−5 on the right (where 2x−6 is positive).
Where the inside of the absolute value bars hits zero, the graph bends and the bars flip the sign of just the part inside them on the negative side.
Key concepts
Every piecewise or absolute value problem starts by locating the border where the rule changes:
Evaluating vs. graphing a piecewise function
The border is the cutoff number in the zones on the right. To evaluate at one input, check the zones first and plug into only the rule for that zone (the border value goes to the rule with ≤ or ≥). To graph the whole function, plug the border x-value into both rules so you can mark the open circle and closed dot right on the border, then follow each slope outward (or draw flat horizontal steps when the rules are constant numbers with no x).
Writing a piecewise equation from a graph
Use the border and the open or closed circles to write the zones, then find y=mx+b for each piece. When a piece crosses the y-axis, read b straight from the graph. When it doesn't, extend its line from the border endpoint to x=0 to find b.
Absolute value functions
The border is where the inside of the bars equals zero. To graph y=a∣x−h∣+k with a=0 or write its equation from a V-graph, you don't need two separate line equations. Set the inside to zero to find the vertex (h,k), and use a as the slope of the right branch and −a as the slope of the left branch. Only split the bars when rewriting in curly-bracket form: at the border where the inside equals zero, drop the bars on the positive side, and put parentheses with a minus sign in front of only the inside expression on the negative side.
9
Practice
1
Given f(x)={−3x+4x−5if x<2if x≥2, find f(−1),f(5), and f(2).
Compare each input to the border x=2 first: which zone includes numbers less than 2, greater than 2, and right on 2?
For x=−1: Since −1<2, use the top rule:
f(−1)=−3(−1)+4=3+4=7
For x=5: Since 5≥2, use the bottom rule:
f(5)=5−5=0
For x=2: Watch out for the slip of plugging the border value 2 into the top rule −3(2)+4 to get −2; the top zone is strictly less than 2(x<2), while the ≥ bar puts x=2 in the bottom rule:
f(2)=2−5=−3
Answerf(−1)=7,f(5)=0, and f(2)=−3.
2
A print shop charges $8 per poster for orders of up to 15 posters, and $5 per poster for orders of more than 15 posters. Write a piecewise function C(x) for the total cost of x posters, and find how much you save by ordering 16 posters instead of 12.
Where is the border where the price changes, and does "up to 15 posters" mean < or ≤?
The price changes at the border of 15 posters. "Up to 15 posters" includes 15(0<x≤15) at $8 each, and "more than 15 posters" is strictly above 15(x>15) at $5 each (putting < on the top zone and ≥ on the bottom zone would wrongly price 15 posters at $75 instead of $120):
C(x)={8x5xif 0<x≤15if x>15
Evaluate C(12) in the top zone and C(16) in the bottom zone (don't stop after finding C(16)=$80, subtract the two totals to find the savings):
C(12)C(16)=8(12)=$96,=5(16)=$80
AnswerC(x)={8x5xif 0<x≤15if x>15. Since C(12)=$96 and C(16)=$80, you save $16.
3
Graph f(x)={−2x+1x+2if x≤1if x>1 by finding the border, the coordinates and circle type (open or closed) of both endpoints on the border, and one additional point on each ray.
Plug the border x=1 into both rules first, then be careful with how a slope of −2 steps when you move to the left of the border.
Left ray (x≤1)Plugging the border x=1 into −2x+1 gives −2(1)+1=−1, which is a closed dot at (1,−1) because of the ≤ bar. Normally a slope of −2 goes down 2 and right 1, so to draw to the left of x=1 we reverse both directions and go up 2 and left 1 to (0,1) (going down 2 and left 1 is a common slip that gives (0,−3) and flips the slope to +2).
Right ray (x>1)Don't start the right piece at the next whole number x=2, which would leave a gap between 1 and 2; plug the border x=1 into x+2 to put an open circle at (1,3), then follow the slope of 1 up 1 and right 1 to (2,4).
AnswerBorder at x=1. Left ray: closed dot at (1,−1), extending left through (0,1). Right ray: open circle at (1,3), extending right through (2,4).
4
A tool rental shop charges a flat fee of $20 for up to 2 hours, $35 for more than 2 hours up to 4 hours, and $50 for more than 4 hours up to 6 hours. Write the step function f(x) for the cost of renting a tool for x hours and describe the three horizontal segments on its graph.
Since the fee is flat inside each time window, should the rules have an x attached to the numbers, and which end of each step gets the closed dot?
Because each fee is a flat dollar amount rather than an hourly rate, the rules are just the constant numbers 20,35, and 50 (attaching an x to write 20x,35x, and 50x would turn the flat steps into slanted lines).
Each "more than ... up to ..." window starts with < (an open circle on the left endpoint) and ends with ≤ (a closed dot on the right endpoint).
Answerf(x)=⎩⎨⎧203550if 0<x≤2if 2<x≤4if 4<x≤6. The graph has three horizontal segments: from an open circle at (0,20) to a closed dot at (2,20), from an open circle at (2,35) to a closed dot at (4,35), and from an open circle at (4,50) to a closed dot at (6,50).
5
Write the piecewise function for a graph that has a left ray passing through (0,4) and ending at an open circle at (3,1), and a right ray starting at a closed dot at (3,−2) and passing through (4,1).
After finding the slope of the right ray from (3,−2) to (4,1), how many steps backward do you need to take from x=3 to find where that line would cross x=0?
ZonesBoth rays meet the border at x=3, with an open circle on the left ray (x<3) and a closed dot on the right ray (x≥3).
Left rule (x<3)From (0,4) to (3,1) the line goes down 3 and right 3 for a slope of m=3−3=−1, and it crosses the y-axis at b=4, giving −x+4.
Right rule (x≥3)From (3,−2) to (4,1) the line goes up 3 and right 1, so m=3. Don't use the border endpoint's y-value −2 as the y-intercept b (which gives the wrong rule 3x−2); step backward left 1, down 3 three times from (3,−2) to reach the y-axis:
(3,−2)left 1, down 3(2,−5)left 1, down 3(1,−8)left 1, down 3(0,−11)⟹b=−11
Answerf(x)={−x+43x−11if x<3if x≥3.
6
Graph y=−3∣x+2∣+1 by finding the vertex and one point on each branch next to the vertex.
Watch out for the slip of reading +2 directly from ∣x+2∣ and placing the vertex at (2,1).
What x-value makes the expression x+2 inside the bars equal zero, and which way do both branches go when a=−3?
Find the vertexSet the inside of the bars to zero: x+2=0⟹x=−2 (watch out for the slip of reading +2 directly from ∣x+2∣ and placing the vertex at (2,1)). With +1 outside the bars, the vertex is at (−2,1).
Step out using a=−3From (−2,1), go down 3 and over 1 in both directions to (−3,−2) and (−1,−2).
AnswerVertex at (−2,1), with branches going down 3 and over 1 in both directions through (−3,−2) and (−1,−2).
7
Write the equation of an absolute value function whose V-shaped graph has its vertex at (4,−3) and passes through (5,−1).
Writing ∣x+4∣ is the common slip here, which puts the vertex at x=−4 instead of 4.
What expression inside the bars becomes zero when you plug in x=4, and what is the rise-over-run from (4,−3) to (5,−1)?
Vertex (4,−3)For the inside of the bars to equal zero at x=4, we need ∣x−4∣ (writing ∣x+4∣ is the common slip here, which puts the vertex at x=−4 instead of 4). Putting the y-value −3 outside gives ∣x−4∣−3.
Slope aFrom the vertex (4,−3) to (5,−1), we go up 2 and right 1, so a=2.
Answery=2∣x−4∣−3.
8
Rewrite f(x)=∣3x+6∣−4 as a piecewise function with simplified rules and no absolute value bars.
Set 3x+6=0 to find the border, then when you replace the bars with parentheses and a minus sign in front for the negative zone, does the −4 outside the bars go inside the parentheses or stay outside?
Find the borderSet the inside expression equal to zero:
3x+6=0⟹3x=−6⟹x=−2
Positive zone (x≥−2)Drop the bars and simplify:
(3x+6)−4=3x+2
Negative zone (x<−2)Replace the bars with parentheses and a minus sign in front of only the inside expression (don't wrap the parentheses around the outside −4 as −(3x+6−4), which wrongly flips −4 to +4 and gives −3x−2):