|<< prev chpt||next chpt >>|
1 Piecewise-defined functions
A piecewise-defined function is a function that has more than one “part” or “piece” to it. For example, this is a piecewise-defined function that uses the variable x:
Note that, in this case, we have three different “formulas” for f(x): x2, 3x − 2, and 2x + 1. But remember, with a function, when you evaluate f(x), you should get ONE ANSWER—not three. Otherwise, you don’t have a function.
How do you know which answer you should have (i.e., which formula you should use)? The “formula” is chosen using the right-side of the piecewise-defined function (the “if …” part). For example, suppose we wanted to find f( − 6). Since − 6 < − 4, we will use the first “formula”:
f( − 6) = ( − 6)2 = 36.
If we want to find f(18), since 18 > 7, we use the third “formula”:
f(18) = 2(18) + 1 = 37.
What about finding f( − 4)? Note that − 4 appears in two of the “if” statements above. Which do we choose? We choose the portion that allows x to equal − 4; in other words, we use the second “formula”:
f( − 4) = 3( − 4) − 2 = − 14.
Here is another example of how to evaluate a piecewise function:
2 Graphing a piecewise-defined function
How do we graph a piecewise-defined function? Let’s look at a simple example. Suppose we want to graph:
First, we will look at the first part of the graph. To graph y = x2 − 4, let’s use what we know. This is a parabola that opens up, and it is shifted down 4 units. So our graph looks like this:
We’re interested in the portion of the graph that corresponds to , so let’s darken that portion in. We can erase the rest of the graph—we don’t need it. We do, however, need to indicate that this portion of our graph is “stopping” when x = 3. Using our “formula”, we know that when x = 3, our y-coordinate will be (3)2 − 4 = 5. Since we have for this part of our function, we will use a solid dot at the point (3, 5).
Now we need to graph the rest of our function: f(x) = x − 2 when x > 3. We’ll graph that portion:
The dotted line is the graph of this second portion. But remember, we only need to portion that corresponds to x > 3. We’ll darken that portion in and erase the rest.
We need a way to show the “starting point” for our second piece. The second piece “starts” when x = 3 (so when y = 3 − 2 = 1), so we need some sort of designation at the point (3, 1). However, remember that we cannot include the point (3, 1) in our graph, so we will use an open circle to designate the beginning of this piece of our graph.
This is the graph of our function.
Here is another example of how to graph a piecewise function:
3 Creating a piecewise-defined function from a word problem
Creating a piecewise-defined function from a word problem is simply a matter of translating the words into symbols. Consider this example:
Example: The Mad Hatter is ordering cups from Teacups, Limited, for his tea party. The Teacups, Limited catalog prices cups according to the number of cups ordered. For orders of 20 or fewer cups, the price is $1.40 per cup plus $12 shipping and handling on the order. For orders of more than 20 cups, the price is $1.10 per cup plus $15 shipping and handling.
a) Write a function to describe the price of cups.
b) How much will it cost the Mad Hatter to order 16 cups?
c) If the Mad Hatter wants to spend at most $45, what is the maximum number of cups he can order?
a) To write our function, we need a variable to represent the number of cups and a variable to represent the cost. Let’s use x for the number of cups and C(x) for the cost of x cups. Then, if we order 20 or fewer cups, our cost is $1.40 times the number of cups plus $12 shipping and handling; that is, C(x) = 1.40x + 12. If we order more than 20 cups, our cost is $1.10 times the number of cups plus $15 shipping and handling; that is, C(x) = 1.10x + 15. Our function looks like this:
b) If the Mad Hatter wants to order 16 cups, we need to use our function when x = 16. Since x < 20, we’ll use the first part of our function: C(16) = 1.40(16) + 12 = $34.40.
c) If the Mad Hatter wants to spend $45, we know that C(x) = $45.00. We need to find the value of x. Since our original function has two pieces, we will actually need to try to use both pieces to solve this problem. Let’s start with the first piece:
If C(x) = $45.00, then we must have 1.40x + 12 = 45. We need to solve this for x:
- 1.40x + 12 = 45
- 1.40x = 33
Dividing by 1.40 give us:
- x = 23.57 (rounded).
Now, since we know that this first piece of our function only works when , we know that we cannot order 23 cups—so this cannot possibly be the correct answer. Let’s try the other piece:
If C(x) = $45.00, then we must have 1.10x + 15 = 45. Solving for x gives us:
- 1.10x + 15 = 45
- 1.10x = 30
- x = 27.27 (rounded)
We can’t buy 0.27 of a cup, so the best we can do is x = 27. This fits with our restriction that x > 20, so x = 27 is our answer.
Try one for yourself. Move your mouse over the solution box to see the solution. If you have trouble check out the pencast below.
Mary's water bill changes as the amount of water used changes. If Mary uses less than 100 gallons of water the cost is 10 cents a gallon. If Mary uses 100 gallons to 500 gallons the cost is 15 cents a gallon plus a $20 fee to encourage conservation. If Mary uses over 500 gallons the cost is 20 cents a gallon plus a $50 fee to encourage conservation. Write a piecewise function to represent the cost of water with x representing the amount of water used in gallons and C(x) representing the cost of water in dollars.