1.5: Piecewise Defined Functions
Piecewise Defined Functions
If a function describing a relationship between two quantities does not have a constant rate of change, we can't use a linear function to model the relationship. At this point, it is only linear functions that we have fully developed for use in modeling relationships. We know what the graph looks like (a line), what the formula looks like (y = mx+ b), what the rate of change is, how these are related, and when to use a linear function (the rate of change is constant). Moving forward, our goal is develop more functions in a similar way to describe relationships without a constant rate of change. In this section, we explore piecewise defined functions which are built with pieces of two or more functions on different intervals.
We have already worked with one piecewise defined function, the absolute value function \(f(x)=\left|x\right|\). For a positive number, such as \(x=3\), the absolute value is the same as the number inputted, \(\left|3\right| = 3\). For a negative number, such as \(x=-2\), the absolute value is the opposite of the number inputted, \(\left|-2\right| = -(-2) = 2\). There are two different rules or ways of calculating the absolute value of a number. In general, if \(x\) is a positive number or zero where \(x \ge 0\), the absolute value is the same as the number inputted, \(\left|x\right| = x\). If \(x\) is a negative number where \(x < 0\), the absolute value is the opposite of the number inputted, \(\left|x\right| = -x \). We can write the absolute value function as a piecewise defined function as follows \[\left|x\right|=\left\{\begin{array}{ccc} {x} & {if} & {x \ge 0} \\ {-x} & {if} & {x < 0} \end{array}\right.\nonumber \]
To graph the absolute value function, we need to graph each formula in the piecewise defined function only in the interval where it is defined. The formula \(y=x\) is a line with slope \(m=1\) and y-intercept at \(y=0\). We need to graph with line only where it is defined for the absolute value \(x \ge 0\). The formula \(y=-x\) is a line with slope \(m=-1\) and y-intercept at \(y=0\). We need to graph with line only where it is defined for the absolute value \(x < 0\). Graphing each piece separately on the interval they are defined on, we have
Putting them on the same graph, we have the graph of the absolute value function below with the different pieces highlighted in different colors.
Given the piecewise defined function \(g(x)=\left\{\begin{array}{ccc} {2x+1} & {if} & {x > 2} \\ {3} & {if} & {x \le 2} \end{array}\right.\)
- Evaluate \(g(1)\)
- Evaluate \(g(2)\)
- Evaluate \(g(3)\)
- Evaluate \(g(4)\)
- Graph \(g(x)\)
Solution
- Since the input \(x=1 \le 2\), we use the second function \(y=3\) to calculate the output. So \(g(1)=3\).
- Similarly, since the input \(x=2 \le 2\), we again use the second function \(y=3\) to calculate the output. So \(g(2)=3\).
- Since the input \(x=3 > 2\), we use the first function \(y=2x+1\) to calculate the output. So \(g(3)=2(3)+1 = 7\).
- Similarly, since the input \(x=4 \ge 2\), we use the first function \(y=2x+1\) to calculate the output. So \(g(4)=2(4)+1 = 9\).
- We need to graph each piece of the function on the interval it is defined on. The formula \(y=2x+1\) is a line with slope \(m=2\) and y-intercept at \(y=1\). The formula \(y=3\) is a horizontal line with a y-intercept at \(y=3\). Graphing each piece separately on the interval they are defined on, we have
At \(x=2\), we have to differentiate which point we want on the graph. We use a closed circle on the graph of \(y=3\) at the point (2,3) to include this point as part of the graph since the formula prescribes that we use \(y=3\) at \(x=2\). We use an open circle on the graph of \(y=2x+1\) at the point (2,5) to exclude this point from the graph since the formula prescribes that we don't use \(y=2x+1\) at \(x=2\).
Putting them on the same graph, we have the graph of \(y=g(x)\).
.
How would the graph in example 1.5.1 change if the function \(g\) was changed to \(g_{new}(x)=\left\{\begin{array}{ccc} {2x+1} & {if} & {x \ge 1} \\ {3} & {if} & {x < 1} \end{array}\right.\)
Solution
The two pieces are the same as \(g\), but the interval where they are defined has change. The first function is defined on \(x \ge 1\), while the second function is defined on \(x < 1 \). We need to adjust the graph accordingly.
Notice that both functions meet at a single point \(y=3\) at \(x = 1\) so there is not need to differentiate between points at \(x = 1\) like we did in the previous example.
Given the piecewise defined function \(f(x)=\left\{\begin{array}{ccc} {x^{2} } & {if} & {x\le 1} \\ {3} & {if} & {1<x\le 2} \\ {6-x} & {if} & {x>2} \end{array}\right.\)
- Evaluate \(f(0)\)
- Evaluate \(f(1)\)
- Evaluate \(f(2)\)
- Evaluate \(f(3)\)
- Graph \(f(x)\)
Solution
- Since the input \(x=0 \le 1\), we use the first function \(y=x^2\) to calculate the output. So \(f(0)=0^2=0\).
- Similarly, since the input \(x=1 \le 1\), we again use the first function \(y=x^2\) to calculate the output. So \(f(1)=1^2 =1\).
- Since the input \(x=2 > 1\) and \(x=2 \le 2\) , we use the second function \(y=3\) to calculate the output. So \(f(2)=3\).
- Similarly, since the input \(x=3 > 2\), we again use the third function \(y=6-x\) to calculate the output. So \(f(3)=6-3 =3\)
- To graph \(f(x)\) we need to graph each piece of the function on the interval it is defined on. The formula \(y=x^2\) is a parabola which changes direction at \(x = 0\). We can graph this function with points or with a graphing calculator or similar technology. We only need the piece where \(x \le 1\). The formula \(y=3\) is a horizontal line with a y-intercept at \(y=3\). The formula \(y=6-x\) is a line with slope \(m=-1\) and y-intercept at \(y=6\). Graphing each of these separately.
Notice that we used closed circles to indicate the points included in the graph at a place where the formula changes corresponding to a \( \le \) or \( \ge \) symbol. We used open circles to indicate the points that are excluded from the graph at a place where the formula changes corresponding to a < or > symbol. Now that we have each piece individually, we combine them onto the same graph below.
Given the piecewise defined function \(h(x)=\left\{\begin{array}{ccc} {3x-1} & {if} & {x\ge 1} \\ {-2x+5} & {if} & {x<1} \end{array}\right.\)
- Evaluate \(h(0)\)
- Evaluate \(h(1)\)
- Evaluate \(h(2)\)
- Graph \(h(x)\)
- Answer
-
- \(h(0)=3\).
- \(h(1) =2\).
- \(h(2) =5\)
Find a formula for a piecewise defined function \(y=f(x) \) whose graph is given below.
- Answer
-
The formula is \(f(x)=\left\{\begin{array}{ccc} {2x-1} & {if} & {x < 2} \\ {-2} & {if} & {x \ge 2} \end{array}\right.\).
Focus: Applications of Piecewise Defined Functions
Piecewise defined functions can be used to model relationships between two quantities in applications when there are two are more ways of calculating a particular quantity.
Example \(\PageIndex{4}\)
A museum charges $5 per person for a guided tour with a group of 1 to 9 people, or a fixed $50 fee for 10 or more people in the group. Write a formula for a piecewise defined function relating the number of people, \(n\), to the cost, \(C\).
Solution
A piecewise defined function is appropriate here, since there are two ways of calculating the cost. For \(n \le 9\), the rate of increase in cost is a constant \( \dfrac{$5}{1 \text{ person}}\). Therefore, a linear function would be appropriate with the slope \(m = 5\). Since the cost of \(n=0\) people is \(C=0\), the linear formula for this piece is C = 5 n for values of n under 10. For 10 or more people, the cost is constant C = 50.
\[C(n) = \begin{cases} 5n & if & 0 < n < 10 \\ 50 & if & n \ge 10 \end{cases}\nonumber \]
Example \(\PageIndex{5}\)
A cell phone company uses the function below to determine the cost, C , in dollars for g gigabytes of data transfer.
\[C(g)=\left\{\begin{array}{ccc} {25} & {if} & {0<g<2} \\ {25+10(g-2)} & {if} & {g\ge 2} \end{array}\right.\nonumber \]
- Find the cost of using 1.5 gigabytes of data.
- Find the cost of using 4 gigabytes of data.
Solution
- To find the cost of using 1.5 gigabytes of data where we must use the first formula \(C(g)\) = $25 since \(g = 1.5 < 2\). So \(C(1.5)\) = $25.
- To find the cost of using 4 gigabytes of data we must use the second formula \(C(g) = 25+10(g-2)\) since \(g = 4 \ge 2\). So \(C(4) = 25 + 10(4 - 2) = $45\).
At Pierce College during the 2009-2010 school year tuition rates for in-state residents were $89.50 per credit for the first 10 credits, $33 per credit for credits 11-18, and for each credit over 18 the rate is $73 per credit (www.pierce.ctc.edu/dist/tuit...ition_rate.pdf, retrieved August 6, 2010). Write a piecewise defined function for the total tuition, \(T\), at Pierce College during 2009-2010 as a function of the number of credits taken, \(c\). Be sure to consider a reasonable domain for the piecewise defined function
- Answer
-
\(T(c) = \begin{cases} 89.5c & if & c \le 10 \\ 895 + 33(c - 10) & if & 10 < c \le 18 \\ 1159 + 73(c - 18) & if & c > 18 \end{cases}\) Tuition, \(T\), as a function of credits, \(c\).
A reasonable domain should be whole numbers 0 to (answers may vary), e.g. [0, 23]
Important Topics of this Section
- Using piecewise defined functions
- Graphing with piecewise defined functions
- Modeling with piecewise defined functions