Skip to main content

Section 2.1 Piecewise Functions

A function may be defined by different formulas on different portions of the \(x\)-axis. Such a function is said to be defined piecewise . To graph a function defined piecewise, we consider each piece of the \(x\)-axis separately.

Example 2.4.

Graph the function defined by
\begin{equation*} f(x) = \begin{cases} x +1 \amp \text{if } x\le 1\\ 3 \amp \text{if } x\gt 1 \end{cases}. \end{equation*}
Solution.
Think of the plane as divided into two regions by the vertical line \(x = 1\text{,}\) as shown in FigureΒ 2.5. In the left-hand region (\(x \le 1\)), we graph the line \(y = x + 1\text{.}\) (The fastest way to graph the line is to plot its intercepts, \((-1, 0)\) and \((0, 1)\text{.}\))
Notice that the value \(x = 1\) is included in the first region, so \(f (1) = 1 + 1 = 2\text{,}\) and the point \((1, 2)\) is included on the graph. We indicate this with a solid dot at the point \((1, 2)\text{.}\) In the right-hand region (\(x \gt 1\)), we graph the horizontal line \(y = 3\text{.}\) The value \(x = 1\) is not included in the second region, so the point \((1, 3)\) is not part of the graph. We indicate this with an open circle at the point \((1, 3)\text{.}\)
described in detail following the image
piecewise function
Figure 2.5.

Example 2.6.

Graph the piecewise defined function
\begin{equation*} g(x) =\begin{cases} -1 - x \amp \text { if } x \le -1\\ x^3 \amp \text{ if } x \gt -1 \end{cases}. \end{equation*}
Solution.
described in detail following the image
piercewise defined function
The absolute value function \(f (x) = \abs{x}\) is an example of a function that is defined piecewise.
\begin{equation*} f (x) =\abs{x} = \begin{cases} x \amp \text{if } x\ge 0\\ -x \amp \text{if } x\lt 0 \end{cases} \end{equation*}
To sketch the absolute value function, we graph the line \(y = x\) in the first quadrant and the line \(y = -x\) in the second quadrant.

Example 2.7.

  1. Write a piecewise definition for \(g(x) = \abs{x - 3}\text{.}\)
  2. Sketch a graph of \(g(x) = \abs{x - 3}\text{.}\)
Solution.
  1. In the definition for \(\abs{x}\text{,}\) we replace \(x\) by \(x - 3\) to get
    \begin{equation*} g(x) =\abs{x-3} = \begin{cases} x-3 \amp \text{if }~ x-3\ge 0\\ -(x-3) \amp \text{if }~ -(x-3)\lt 0 \end{cases}. \end{equation*}
    We can simplify this expression to
    \begin{equation*} g(x) =\abs{x-3} = \begin{cases} x-3 \amp \text{if }~ x\ge 3\\ -x+3 \amp \text{if }~ x\lt 3 \end{cases}. \end{equation*}
  2. In the first region, \(x \ge 3\text{,}\) we graph the line \(y = x - 3\text{.}\) Because \(x = 3\) is included in this region, the endpoint of this portion of the graph, \((3, 0)\text{,}\) is included, too.
    In the second region, \(x \lt 3\text{,}\) we graph the line \(y = -x + 3\text{.}\) Note that the two pieces of the graph meet at the point \((0, 3)\text{,}\) as shown in FigureΒ 2.8.
    described in detail following the image
    piecewise function
    Figure 2.8.

Subsection 2.1.1 Domain and Range

To identify the domain and range of a piecewise function, we recall that a piecewise function is defined by different functions each with corresponding domains.
Then the domain of the piecewise function is the combination of these domains, and the range of the piecewise function is the combination of the ranges of the functions on their corresponding domains. This idea is better illustrated in the following example.

Example 2.9.

Find the domain and range of the function
\begin{equation*} f(x) = \begin{cases} x^2 -6 \amp \text{if } 0\le x\le 4\\ -x+10 \amp \text{if } 5\le x\lt 10 \end{cases}. \end{equation*}
Solution.
By definition, we see that \(f\) is comprised of two functions:
Then the domain of \(f \) is the combination of the domains of the two functions listed above. We represent this as
\begin{equation*} [0,4]\cup [5,10). \end{equation*}
The symbol "\(\cup\)" is shorthand for the word "and".
Each of the functions which make up \(f\) were considered in the Domain and Range SectionΒ 1.3 as examples. Putting together the two graphs, we get the graph of \(f \text{:}\)
described in detail following the image
piecewise function
Figure 2.10.
In the Domain and Range SectionΒ 1.3 we found that the range of \(x^2-6\) on the domain \(0\le x\le 4\) is \([-6,10]\text{.}\) Additionally, we found that the range of \(-x+10\) on the domain \(5\le x\lt 10\) is \((0,5]\text{.}\) Then the range of \(f \) is the combination of these two ranges:
\begin{equation*} [-6,10]\cup(0,5]. \end{equation*}
However, notice that we can simplify this a bit. Since the values in the interval \((0,5]\) are contained in the interval \([-6,10]\) and thus
\begin{equation*} [-6,10]\cup(0,5]=[-6,10]. \end{equation*}

Exercises 2.1.2 Exercises

1. Identifying Domain.

Determine which values of \(x\) would cause the function \(g\left(x\right) = \dfrac{1}{x + 3}\) to be undefined. What does this tell you about the domain of \(g(x)\text{?}\)
The value(s) \(x=\) make the function \(g(x)=\dfrac{1}{x + 3}\) undefined.
Domain of \(g(x)\text{:}\)
Hint.
We want to find where the function \(g(x)=\frac{1}{x + 3}\) is undefined to help us find the domain. We have an undefined fraction when we divide by 0.
This is the only value we can not include in the domain.

2. Evaluating and Identifying Domain of a Piecewise Function.

Let \(h(x)=\begin{cases}\displaystyle{3}\amp \text{if}\ x \le -2\cr \displaystyle{5-x^{2}}\amp \text{if}\ -2 \lt x \lt 3\cr \displaystyle{2x-3}\amp \text{if}\ 3 \lt x\end{cases}\text{.}\)
a) Evaluate the following:
i) \(h(-3)=\)
ii) \(h(-2)=\)
iii) \(h\left(\frac{1}{2}\right)=\)
iv) \(h(2) =\)
v) \(h(6)=\)
b) What is the domain of this function?
Domain:
Hint.
a) For this part, we want to evaluate the function at several input values. We will need to look at the value of each input and compare it to the restrictions on the function to see which piece of the function we need to use.
For example, if you wanted to evaluate \(f(-50)\text{,}\) you’d use the first equation since \(-50\lt -2\text{.}\)
b) To find the domain of this function, we need to figure out all the possible input values where the function is defined. We can do this by looking at the restrictions for each piece of the function.
Pay close attention to the inequalities to see if there are any values of \(x\) that are not included here. Make sure you also combine any intervals you can.
For example \((-\infty,5]\cup(5,\infty)\) can be rewritten as \((-\infty,\infty)\) because 5 is included in the left interval.

3. Graph of Piecewise Function.

Let
\begin{equation*} f(x)=\begin{cases}\displaystyle{-x-3}\amp \text{if}\ x \lt -2\cr \displaystyle{\frac{2x}{3}}\amp \text{if}\ -2 \le x \le 3\cr \displaystyle{1}\amp \text{if}\ 3 \lt x\end{cases}. \end{equation*}
Which of the following graphs is the graph of \(f(x)\text{?}\)
A B
C D
(Click on a graph to enlarge it)
Hint.
One way to figure out which graph represents the piecewise function
\begin{equation*} f(x)=\begin{cases}\displaystyle{-x-3}\amp \text{if}\ x \lt -2\cr \displaystyle{\frac{2x}{3}}\amp \text{if}\ -2 \le x \le 3\cr \displaystyle{1}\amp \text{if}\ 3 \lt x\end{cases}, \end{equation*}
is to look at the restrictions given by each piece of the function. This information will tell us about open and closed circles on the graph and where those should occur.
It may be good to pick out an equation in the piecewise function that is easily identifiable on a graph (if possible). In this case, we have the equation that \(f(x)=1\) for \(x>3\text{.}\) This is a horizontal line on the graph. Find the graph(s) which have the horizontal line in the right place.

4. Writing Formula of Piecewise Function.

Find a formula for the piecewise function graphed in the figure. Assume the entire graph of \(f(x)\) is shown in the graph. end. (a) The formula for the left piece of \(f(x)\) is \(f(x) =\) for all \(x\) that satisfy the inequality (b) The formula for the middle piece of \(f(x)\) is \(f(x) =\) for all \(x\) that satisfy the inequality (c) The formula for the right piece of \(f(x)\) is \(f(x) =\) for all \(x\) that satisfy the inequality
Hint.
a) We can find the equation of the left piece of the graph by finding the linear function between the points \((-1,-3)\) and \((0,-5)\text{.}\) Recall the slope formula
\begin{equation*} m=\frac{y_2-y_1}{x_2-x_1}. \end{equation*}
We can use either of the points to find the equation of the left piece using the Point-Slope form:
\begin{equation*} y=y_1+m(x-x_1). \end{equation*}
To find the inequality, look at the inputs where this part of the function occurs. Pay special attention open and closed circles.
b) We see the middle section of the graph is a horizontal line. Recall a horizontal line has the equation \(y=k\) for some constant \(k\text{.}\)
Again, consider the inputs where this part of the function occurs to find the inequality.
c) Finally, we use a similar method to the one used in part a) to find the equation of the right section of the graph.
You’ll do the same thing as above to find the inequality.

5. Writing Formula and Graphs for a Word Problem.

Fred has a piggy bank. On his twelfth birthday, he started saving money. Every week, on the first day of the week, he puts half of his $ 30 allowance into the bank. Write a formula for \(f(t)\text{,}\) the amount of money in his piggy bank \(t\) days after his twelfth birthday, on the domain \(0 \leq t \leq 28\text{.}\) You may assume that Fred’s first deposit was made on his birthday, i.e. on day \(t=0\text{,}\) which is on the first day of the week.
a) Fill in the missing values in the table below.
\(t\) 0 4 7 9 14 20 21 25 28
\(f(t)\)
b) Which of the following graphs is a graph of the function \(f(t)\text{?}\)
A B C D
(Click on a graph to enlarge it)
Hint.
It’s important to note that Fred deposits 15 dollars into his piggy bank every week on the same day. Therefore, between deposits, his piggy bank value (i.e., the value of \(f(t)\)) stays constant.
a) To fill in the table, we should start with 15 dollars on \(t=0\text{.}\) The value of \(f(t)\) should increase on every multiple of 7, because that’s the day he deposits another 15 dollars into his piggy bank.
b) To choose the right graph, we can use our table as a guide. Since the piggy bank value is constant between deposits, we should be looking for horizontal lines on values that represent non-deposit days of the week. Be sure to check specific points to determine the correct graph.

6. Writing Formula for a Word Problem.

An art professor wishes to take his class on a trip to the Art Institute of Chicago. The Art Institute has several different pricing options for groups:
\(\cdot\) $ 24 per person for group sizes up to 14 people (this is the standard individual rate);
\(\cdot\) $ 21 per person for group sizes from 15 to 25 people;
\(\cdot\) $ 18 per person for group sizes of 26 people or more.
For groups of at least 15 people, the group must also book their tickets ahead of time, and pay a flat reservation fee of $ 20. For groups of size 14 people or fewer, there is no reservation fee.
a) Fill in the missing values of the table showing the cost of admittance, \(C(n)\) for a group of \(n\) people, for \(n\) from 0 to 30, in increments of 5 people.
\(n\) 0 5 10 15 20 25 30
\(C(n)\)
b) Write a piecewise function for \(C(n)\text{.}\)
\(0\leq\)\(x\leq\)
\(C(n)=\)
\(\leq x\leq\)
c) How much will it cost to buy tickets for the professor plus 16 students?
dollars
d) If the professor’s budget is $ 192, how many students can he take (that is, how many people in addition to himself)?
students
Hint.
a) To fill in the table, we have the following rules:
\(\cdot\) For input values less than or equal to 14, multiply the input value by 24.
\(\cdot\) For input values between (inclusive) 15 and 25, multiply the input value by 21 and add 20 for the additional reservation fee.
\(\cdot\) For input values greater than or equal to 26, multiply the input value by 18 and add 20 for the additional reservation fee.
b) To write the piecewise function \(C(n)\text{,}\) we will essentially translate the above statements into mathematical equations. This will consist of linear functions in each slot.
c) To find how much it costs for the teacher plus 16 students, we will plug in \(n=17\) to our function \(C(n)\text{.}\) You’ll need to determine which equation to use by looking at the restrictions of the function pieces.
d) Finally, to find out how many people the teacher can take, in addition to himself, with the budget 192 dollars, we need to use each equation of \(C(n)\) until we find an answer in the right domain. In other words, we will set each piece of the function equal to 192 and choose the appropriate answer from there.
Be sure to subtract 1 from the value you find to the number of students he can take with him.

7. Writing Formula and Graphs for a Word Problem.

A section of highway has a 65 mph speed limit. If you are caught speeding between 66 and 84 mph, your fine is $ 40 plus $3 for every mile over 65 mph. For 85 mph and higher, your fine is $ 145 plus $5 for every mile per hour over 85. For this problem, assume your car can reach a maximum speed of 120 mph (although we don’t encourage you to drive that fast.)
a) How much would you be fined if you were caught traveling
i) 70 mph? dollars
ii) 95 mph? dollars
b) What is the difference of the speeding ticket cost if you are caught going 84 mph versus 85 mph? Note: Your answer should be positive.
dollars
c) Write a function \(C=f(s)\) where \(C\) represents the cost of the ticket and \(s\) represents the speed.
d) Which of the following graphs represents this situation?
A B C
(Click on a graph to enlarge it)
e) What are the domain and range in the graph of the cost function from part b)? Remember we are assuming your car can reach a maximum speed of 120 mph.
Domain:
Range:
Hint.
a) We will use the given information to answer these questions.
i) If you drive 70 mph, you are driving 5 mph over the speed limit. Therefore, the ticket will cost 40 plus 3 dollars for each of the 5 mph.
ii) If you drive 95 mph, you are driving 10 mph over the restriction of 85. Therefore, the ticket will cost 145 plus 5 dollars for each of the 10 mph.
b) For this part, we want to calculate the cost of a ticket driving at 75 mph and the cost of a ticket driving at 74 mph and subtract the two.
We can break down the information from the problem in the following way:
\(\cdot\) The ticket will cost 40 plus 3 times the number of mph over 65 when driving at speeds between 66 and 84 mph.
\(\cdot\) The ticket will cost 145 plus 5 times the number of mph over 85 when driving at speeds between 85 and 120 mph.
The number of mph above 65 mph is given by the expression "\(s-65\)" and the number of mph above 85 is given by the expression "\(s-85\)".
d) One way to determine which graph represents the situation, we can find the ordered pairs associated with some of the relevant information in the problem. In particular, it is useful to find the ordered pairs associated with \(s=66\text{,}\) \(s=84\text{,}\) \(s=85\) and \(s=120\text{.}\)
The graph we want has these ordered pairs with linear functions connecting the first two and the second two. Notice that we don’t really consider what happens if you are driving between 84 mph and 85 mph because we are only considering whole number values.
e) We can use the information from part d) to find the domain and range.