Learning Objectives
In this section, you will:
- Define a piecewise-defined function..
- Evaluate a piecewise-defined function.
- Graph a piecewise-defined function.
- Interpret the graph of a piecewise-defined function.
Let’s Get Started Graphing Piecewise-Defined Functions
Sometimes, we come across a function that requires more than one formula in order to obtain the given output. For example, consider the absolute value function [latex]f\left(x\right)=|x|[/latex]. With a domain of all real numbers and a range of values greater than or equal to 0, absolute value can be defined as the magnitude, or modulus, of a real number value regardless of sign. It is the distance from 0 on the number line. All of these definitions require the output to be greater than or equal to 0.
If we input 0, or a positive value, the output is the same as the input.
If we input a negative value, the output is the opposite of the input.
Because this requires two different processes or pieces, the absolute value function is an example of a piecewise function. A piecewise function is a function in which more than one formula is used to define the output over different pieces of the domain.
We use piecewise functions to describe situations in which a rule or relationship changes as the input value crosses certain “boundaries.” For example, we often encounter situations in business for which the cost per piece of a certain item is discounted once the number ordered exceeds a certain value. Tax brackets are another real-world example of piecewise functions. For example, consider a simple tax system in which incomes up to $10,000 are taxed at 10%, and any additional income is taxed at 20%. The tax on a total income [latex]S[/latex] would be [latex]0.1S[/latex] if [latex]S\le \text{\$}10\text{,}000[/latex] and [latex]\text{\$}1000+0.2\left(S-\text{\$}10\text{,}000\right)[/latex] if [latex]S\gt\text{\$}10\text{,}000[/latex].
Piecewise Function
A piecewise function is a function in which more than one formula is used to define the output. Each formula has its own domain, and the domain of the function is the union of all these smaller domains. We notate this idea like this:
In piecewise notation, the absolute value function is
How To
Given a piecewise function, write the formula and identify the domain for each interval.
- Identify the intervals for which different rules apply.
- Determine formulas that describe how to calculate an output from an input in each interval.
- Use braces and if-statements to write the function.
EXAMPLE 1
Writing a Piecewise Function
A museum charges $5 per person for a guided tour with a group of 1 to 9 people or a fixed $50 fee for a group of 10 or more people. Write a function relating the number of people, [latex]n[/latex], to the cost, [latex]C[/latex].
Show/Hide Solution
Solution
Two different formulas will be needed. For [latex]n-[/latex]values under 10, [latex]C=5n[/latex]. For values of [latex]n[/latex] that are 10 or greater, [latex]C=50[/latex].
Analysis
The function is represented in Figure 1. The graph is a diagonal line from [latex]n=0[/latex] to [latex]n=10[/latex] and a constant after that. In this example, the two formulas agree at the meeting point where [latex]n=10[/latex], but not all piecewise functions have this property.
EXAMPLE 2
Working with a Piecewise Function
A cell phone company uses the function below to determine the cost, [latex]C[/latex], in dollars for [latex]g[/latex] gigabytes of data transfer.
Find the cost of using 1.5 gigabytes of data and the cost of using 4 gigabytes of data.
Show/Hide Solution
Solution
To find the cost of using 1.5 gigabytes of data, [latex]C\left(1.5\right)[/latex], we first look to see which part of the domain our input falls in. Because 1.5 is less than 2, we use the first formula.
To find the cost of using 4 gigabytes of data, [latex]C\left(4\right)[/latex], we see that our input of 4 is greater than 2, so we use the second formula.
Analysis
The function is represented in Figure 2. We can see where the function changes from a constant to a shifted and stretched identity at [latex]g=2[/latex]. We plot the graphs for the different formulas on a common set of axes, making sure each formula is applied on its proper domain.
How To
Given a piecewise function, sketch a graph.
- Indicate on the [latex]x-[/latex]axis the boundaries defined by the intervals on each piece of the domain.
- For each piece of the domain, graph on that interval using the corresponding equation pertaining to that piece. Do not graph two functions over one interval because it would violate the criteria of a function.
EXAMPLE 3
Graphing a Piecewise Function
Sketch a graph of the function.
Find the cost of using 1.5 gigabytes of data and the cost of using 4 gigabytes of data.
Show/Hide Solution
Solution
We know the shapes of each of the component functions. We can imagine graphing each function and then limiting the graph to the indicated domain. At the endpoints of the domain, we draw open circles to indicate where the endpoint is not included because of a less-than or greater-than inequality; we draw a closed circle where the endpoint is included because of a less-than-or-equal-to or greater-than-or-equal-to inequality.
Figure 3 shows the three components of the piecewise function graphed on separate coordinate systems.
Figure 3
Now that we have sketched each piece individually, we combine them in the same coordinate plane. See Figure 4.
Figure 4
Analysis
The function is represented in Figure 2. We can see where the function changes from a constant to a shifted and stretched identity at [latex]g=2[/latex]. We plot the graphs for the different formulas on a common set of axes, making sure each formula is applied on its proper domain.
Note that the graph does pass the vertical line test even at [latex]x=1[/latex] and [latex]x=2[/latex] because the points [latex]\left(1,3\right)[/latex] and [latex]\left(2,2\right)[/latex] are not part of the graph of the function, though [latex]\left(1,1\right)[/latex] and [latex]\left(2,\,3\right)[/latex] are.
Try It #1
Graph the following piecewise function.
Section 1.2 Exercises
[Answers to odd problem numbers are provided at the end of the problem set. Just scroll down!]
For the following exercises, sketch a graph of the piecewise function. Write the domain in interval notation.
1. [latex]f\left(x\right)=\Bigg\{\begin{array}{lll}x+1\hfill & \text{if}\hfill & x<-2\hfill \\ -2x-3\hfill & \text{if}\hfill & x\ge -2\hfill \end{array}[/latex]
2. [latex]f\left(x\right)=\Bigg\{\begin{array}{lll}2x-1\hfill & \text{if}\hfill & x<1\hfill \\ 1+x\hfill & \text{if}\hfill & x\ge 1\hfill \end{array}[/latex]
3. [latex]f\left(x\right)=\Bigg\{\begin{array}{ccc}3& \text{if}& x<0\\ \sqrt{x}& \text{if}& x\ge 0\end{array}[/latex]
4. [latex]f\left(x\right)=\Bigg\{\begin{array}{c}x+1\,\,\text{if}\,\,x<0\\ x-1\,\,\text{if}\,\,\,x>0\end{array}[/latex]
5. [latex]f\left(x\right)=\Bigg\{\begin{array}{r}\hfill \begin{array}{r}\hfill {x}^{2}\\ \hfill x+2\end{array}\end{array}\,\,\begin{array}{l}\text{if}\,\,\,\,\,x<0\hfill \\ \text{if}\,\,\,\,\,x\ge 0\hfill \end{array}[/latex]
6.[latex]f\left(x\right)=\Bigg\{\begin{array}{c}{x}^{2}\text{ if }x<0\\ 1-x\text{ if }x>0\end{array}[/latex]
7. [latex]f\left(x\right)=\Bigg\{\begin{array}{c}|x|\\ 1\end{array}\begin{array}{l}\,\,\,\text{if}\,\,\,x<2\hfill \\ \,\,\,\text{if}\,\,\,x\ge 2\hfill \end{array}[/latex]
8. [latex]f\left(x\right)=\Bigg\{\begin{array}{ccc}x+1& \text{if}& x<1\\ {x}^{3}& \text{if}& x\ge 1\end{array}[/latex]
Numeric
For the following exercises, given each function [latex]f,[/latex]evaluate [latex]f\left(-3\right),\,f\left(-2\right),\,f\left(-1\right),[/latex] and [latex]f\left(0\right).[/latex]
9. [latex]f\left(x\right)=\Bigg\{\begin{array}{cc}1& \text{if }x\le -3\\ 0& \text{if }x>-3\end{array}[/latex]
10. [latex]f\left(x\right)=\Bigg\{\begin{array}{lll}x+1\hfill & \text{if}\hfill & x<-2\hfill \\ -2x-3\hfill & \text{if}\hfill & x\ge -2\hfill \end{array}[/latex]
11. [latex]f\left(x\right)=\Bigg\{\begin{array}{cc}-2{x}^{2}+3& \text{if }x\le -1\\ 5x-7& \text{if }x>-1\end{array}[/latex]
For the following exercises, given each function[latex]\,f,\,[/latex]evaluate[latex]f\left(-1\right),\,f\left(0\right),\,f\left(2\right),\,[/latex]and[latex]\,f\left(4\right).[/latex]
12. [latex]f\left(x\right)=\Bigg\{\begin{array}{ccc}{x}^{2}-2& \text{if}& x<2\\ 4+|x-5|& \text{if}& x\ge 2\end{array}[/latex]
13. [latex]f\left(x\right)=\Bigg\{\begin{array}{lll}7x+3\hfill & \text{if}\hfill & x<0\hfill \\ 7x+6\hfill & \text{if}\hfill & x\ge 0\hfill \end{array}[/latex]
14. [latex]f\left(x\right)=\Bigg\{\begin{array}{ccc}{x}^2-5& \text{if}& x<1\\ 4x+5 & \text{if}& 1\le x\le 4\\ \frac{1}{2}x & \text{if}& x>4\end{array}[/latex]
15. [latex]f\left(x\right)=\Bigg\{\begin{array}{ccc}5x& \text{if}& x<0\\ 3& \text{if}& 0\le x\le 3\\ {x}^{2}& \text{if}& x>3\end{array}[/latex]
For the following exercises, write the domain for the piecewise function in interval notation.
16. [latex]f\left(x\right)=\Bigg\{\begin{array}{c}x+1\,\,\,\,\,\text{ if}\,\,x<-2\\ -2x-3\,\,\text{if}\,\,x\ge -2\end{array}[/latex]
17. [latex]f\left(x\right)=\Bigg\{\begin{array}{c}{x}^{2}-2\,\,\,\,\,\text{ if}\,\,x<1\\ -{x}^{2}+2\,\,\text{if}\,\,x>1\end{array}[/latex]
18. [latex]f\left(x\right)=\Bigg\{\begin{array}{c}2x-3\\ -3{x}^{2}\end{array}\,\,\begin{array}{c}\text{if}\,\,\,x<0\\ \text{if}\,\,\,x\ge 2\end{array}[/latex]
Answers to Section 1.2 Odd Problems
1. domain:[latex]\,\left(-\infty ,\infty \right)[/latex]
3. domain:[latex]\,\left(-\infty ,\infty \right)[/latex]
5. domain:[latex]\,\left(-\infty ,\infty \right)[/latex]
7. domain:[latex]\,\left(-\infty ,\infty \right)[/latex]
9. [latex]\begin{array}{cccc}f\left(-3\right)=1;& f\left(-2\right)=0;& f\left(-1\right)=0;& f\left(0\right)=0\end{array}[/latex]
11. [latex]\begin{array}{cccc}f\left(-3\right)=-15;& f\left(-2\right)=-5;& f\left(-1\right)=1;& f\left(0\right)=-7\end{array}[/latex]
13. [latex]\begin{array}{cccc}f\left(-1\right)=-4;& f\left(0\right)=6;& f\left(2\right)=20;& f\left(4\right)=34\end{array}[/latex]
15. [latex]\begin{array}{cccc}f\left(-1\right)=-5;& f\left(0\right)=3;& f\left(2\right)=3;& f\left(4\right)=16\end{array}[/latex]
17. domain:[latex]\,\left(-\infty ,1\right)\cup \left(1,\infty \right)[/latex]