Skip to main content

Section 6.3 Interlude: Piecewise-linear functions

Subsection Late parking ticket

Mallory is having a miserable time. A few weeks back she forgot to pay the parking meter and the city issued a parking ticket. The parking ticket was for $45 and was due within 30 days. After that, the city imposes a late fee of $10. Bummer.
But Mallory is curious – how can she write an equation to describe the cost of her parking ticket when it changes like that? She knows variables are
\begin{align*} D \amp= \text{ time since she got the ticket (days) }\sim \text{ indep}\\ C \amp= \text{ cost of parking ticket (\$) }\sim \text{ dep} \end{align*}
The starting amount (intercept) is $45. What’s the rate of change (slope)? During the first 30 days, the price does not change. Since that rate of change is constant, we have a linear equation and the slope is $0/day. The equation for the first 30 days is
\begin{equation*} C = 45 + 0D \end{equation*}
But \(0D = 0\text{,}\) so really
\begin{equation*} C = 45 \end{equation*}
By the way, there is a name for this type of function. It’s called a constant function. Meaning the value of the ticket is constant, at least during those first 30 days.
Now, after 30 days, the price jumps to \(45+10 = \$55\text{.}\) The equation for the price then is
\begin{equation*} P = 55 \end{equation*}
another constant function.
There’s a notation we can use to describe \(C\) as a function of \(D\) that includes both values. We write
\begin{equation*} C = \left\{ \begin{array}{cl}45 \amp \text{if } 0 \le D \le 30 \\ 55 \amp \text{if } D \gt 30\end{array} \right. \end{equation*}
The way we read this notation is: if the number of days \(D\) is between 0 and 30, then the ticket costs \(P=\) $45 but if the number of days is over 30, then the ticket costs \(C=\) $55.

Subsection Piecewise-linear functions and their graphs

When our equation has two (or more) pieces, it’s called a piecewise-defined function. In this type of situation where both pieces are linear, it’s called a piecewise-linear function.
What does the graph of a piecewise-linear function look like? Let’s make a table of values. Notice any value of \(D\) over 30 days is gonna cost Mallory $55. Even if she’s 2 minutes late, it’s gonna cost $55. Note that 2 minutes late is 30.0014 days since
\begin{equation*} 2 \text{ min}= \frac{2 \text{ min}}{1}\times \frac{1 \text{ hour}}{60 \text{ min}}\times \frac{1 \text{ day}}{24 \text{ hours}}= 2 \div 60 \div 24 = .001388\ldots \approx .0014 \text{ days} \end{equation*}
Here are the values we know.
\(D\) 0 10 20 30 30.0014 40 50
\(C\) 45 45 45 45 55 55 55
When we draw the graph and connect the dots into lines, we notice two things. First, the lines are horizontal. That always happens when the function is constant and the slope is 0. Second, there’s a jump at 30 days where the graph isn’t connected, which makes sense because the cost of the ticket jumps up after 30 days.
Notice how we indicate the values corresponding to \(D=30\text{.}\) We use a solid dot at \((30,45)\) because that’s a point on the graph: at 30 days the parking ticket costs $45. We use an open dot at \((30,55)\) because that’s not a point on the graph: at 30 days the parking ticket is not yet $55.

Subsection Late rent

Mallory’s troubles aren’t over. She’s also behind on the rent. She normally owes \(900\) and there’s a one week grace period, meaning she can pay up to one week late without any late fees. For the next week, the late fee is $10/day. After that, the late fee jumps to $25/day.
Let’s measure time in days. We have
\begin{align*} L \amp= \text{ how late the rent is (days)}\sim \text{ indep}\\ R \amp= \text{ rent plus any late fees (\$)}\sim \text{ dep} \end{align*}
What happens during the first week? For example, when \(L=0\) days, the rent is $900. When \(L=4\) days, we’re within the grace period ( \(0 \le L \le 7\) ) so the rent is still $900. The equation during this week is \(R = 900\text{.}\)
What happens during the second week? For example, when \(L = 10\) days, she’s \(10-7=3\) days late and we’re during the week where it costs an extra $10/day ( \(7\lt L\le14\) ), so the rent is now
\begin{align*} R \amp = 900 + (10-7) \times 10 \\ \amp = 900 + 3 \times 10 \\ \amp = 900 + 30\\ \amp = \$930 \end{align*}
The number of days late after the 7 day grace period is \(L-7\text{.}\) The equation is
\begin{equation*} R = 900 + (L-7)10 \end{equation*}
We can use the distributive property to multiply out to get
\begin{align*} R \amp = 900 + (L-7) \times 10 \\ \amp = 900 + 10L - 70 \\ \amp = 830 + 10L \end{align*}
What happens during the third week? For example, when \(L=20\) days, she pays $900 rent plus $10/day for the first 7 days late plus $25/day for the next \(20-14=6\) days late, so that’s a total of
\begin{align*} R \amp = 900 + 7 \times 10 + (20-14) \times 25\\ \amp = 900 + 70 + 6 \times 25\\ \amp = 970 + 150\\ \amp = \$1120 \end{align*}
Ouch! The number of days where she’s gonna pay an extra $25/day is \(L -14\text{.}\) The equation is
\begin{equation*} R = 900 + 10\times7 + 25(L-14) \end{equation*}
Again, we can use the distributive property to multiply out to get
\begin{align*} R \amp = 900 + 10 \times 7 + 25(L - 14)\\ \amp = 900 + 70 + 25L -25\times 14 \\ \amp = 970 + 25L - 350\\ \amp = 620 + 25L \end{align*}
When we put everything together we get
\begin{equation*} R = \left\{ \begin{array}{cl}900 \amp \text{if } 0 \le L \le 7\\ 830 + 10L \amp \text{if } 7 \lt L \le 14\\ 620+25L\amp \text{if } L \gt 14\end{array} \right. \end{equation*}
In case you were wondering about part days, Mallory’s apartment complex prorates the late fees are prorated by the hour (or even by the minute). So, for example, if Mallory pays her rent 9 days and 6 hours late, we would pay $10/day for those 2 days and 6 hours after the grace period which is
\begin{align*} 2 \text{ days} + 6 \text{ hours} \amp = 2 \text{ days} + \dfrac{6 \text{ hours}}{1} \times \frac{1 \text{ day}}{24 \text{ hours}}\\ \amp 2+6 \div 24\\ \amp 2 + 0.25 = 2.25 \text{ days} \end{align*}
and so the late fee would be prorated at \(2.25 \times 10 = \$22.50\) for a total of \(900 + 22.50 = \$922.50\text{.}\)
Let’s summarize our examples and a few more values in a table.
\(L\) 0 4 7 10 14 15 20
\(R\) 0 900 900 930 970 995 1120
Now we can draw the graph.
Notice that there are no jumps in the graph this time. That’s because when \(L=7\) we know \(R=900\) but if we were to use the equation \(R=830+10L\) when \(L=7\) instead, we would get \(R = 830+10 \times 7 = 900\) again. That tells us that the second line starts where the first horizontal line ends. Similarly, when \(L=14\) we use the equation \(R = 830+10L\) to get \(R = 830+10*14=970\) but if we were to use the equation \(R=620+25L\) when \(L = 14\) instead, then we would get \(R=620+25 \times 14 = 970\) again. This tells us that the third line starts where the second line ends. Sometimes we put closed dots to emphasize where the formula changes.

Subsection Do you know …

  1. Why we might model a situation using a piecewise-linear function?
  2. How to model a situation using a piecewise-linear function?
  3. What a constant function is and what its graph looks like?
  4. How to graph a piecewise-linear function?
  5. How to indicate jumps in the graph of a piecewise-linear function using open and closed points?
If you’re not sure, work the rest of the exercises and then return to these questions. Or, ask your instructor or a classmate for help.

Exercises Exercises

Exercises 1-4 are available in a separate workbook format.

1.

A new bikeshare program rents e-bikes for the flat rate of $10 for up to 30 minutes plus 20Β’/minute thereafter.

(b)

Name the variables, including units, and write a piecewise-linear equation illustrating the dependence. Hint: for times over 30 minutes you’ll have to subtract 30 minutes before multiplying by 20Β’/minute.

(c)

Draw a graph illustrating the dependence. Include values from 0 to 2 hours.

2.

A food delivery app pays drivers a base rate of \(\$1.20\) per mile for the first 5 miles of a delivery. To encourage long-distance deliveries, deliveries with a distance beyond 5 miles pay a bonus rate of \(\$1.80\) per mile (for the miles over 5 miles).

(b)

What does an 8 mile delivery pay? 20 mile delivery? Note: your calculations should include \(8-5\) and \(20-5\text{.}\)

(c)

Name the variables, including units, and write a piecewise-linear equation illustrating the dependence.

(d)

Draw a graph showing the pay for deliveries up to 20 miles. Hint: When you use 5 miles in the equation for over 5 miles you should get the same pay as you found for 5 miles in (a) meaning that the graph does not jump.

3.

Seawater is naturally slightly basic (the opposite of acidic), at a pH of around 8.1. To understand how carbon dioxide ( \(\text{CO}_{2}\) ) makes seawater more acidic (lower pH), Ngene has designed an experiment. She slowly bubbles carbon dioxide ( \(\text{CO}_{2}\) ) gas into a small container of seawater. At first, an active chemical buffer in the seawater slows down the drop in pH (which measures the acidity of the water). For the first \(10\ \text{mL}\) of dissolved \(\text{CO}_{2}\text{,}\) the seawater’s pH drops slowly at a rate of \(0.02\text{ pH units per mL}\text{.}\) (Note: mL stands for milliliter, which is 1/1000th of a liter. The quanity 10mL is about 2 teaspoons.). Once the buffer capacity is exhausted beyond \(10\ \text{mL}\text{,}\) the pH drops rapidly at a steeper rate of \(0.12\text{ pH units per mL}\) making the seawater more and more acidic. Let’s use the variables
\begin{align*} G \amp= \text{ amount of carbon dioxide gas (mL) }\sim \text{ indep}\\ A \amp= \text{ acidity of seawater (pH) }\sim \text{ dep} \end{align*}

(a)

At the point where Ngene has bubbled 5 mL of \(\text{CO}_{2}\) into the container of seawater, what is the pH?

(b)

At the point where Ngene has bubbled 10 mL of \(\text{CO}_{2}\) into the container of seawater, what is the pH?

(c)

Write an equation for \(A\) as a a function of \(G\) for \(0 \le G \le 10\text{.}\) Hint: What is the starting pH? What is the slope? Another hint: The slope is negative.

(d)

At the point where Ngene has bubbled 20 mL of \(\text{CO}_{2}\) into the container or seawater, what is the pH

(e)

Write an equation for \(A\) as a function of \(G\) for \(G \gt 10\text{.}\) Note that the starting value equals your answer from (b) and the slope of -0.12 pH units per mL applies to the amount of gas above 10mL, which is \(G-10\text{.}\)

(f)

Use the distributive property to simplify your answer to (e).

(g)

Write a piecewise-linear function illustrating how pH of Ngene’s container of seawater depends on the amount of \(\text{CO}_{2}\) she introduces.

4.

Oh, dear. Mallory’s having a very bad month. She just realized a book she borrowed from the library is overdue. The library has a grace period of 30 days followed by a fine of 10Β’/day to a max of $5. Notice that books are normally free to borrow from the library, so for up to 30 days late it costs $0.

(a)

What will Mallory owe if the book is 20 days late? 40 days late? 2 months late? (Use 1 month = 30 days).

(c)

Write an equation illustrating the dependence, for late fees up to $5.

(d)

How many days late is a book that is first charged $5? Hint: try guessing. If that doesn’t work, solve your equation from (c).

(e)

Write a piecewise-linear equation illustrating the dependence, for all possible days late.

5.

Tensia planted seeds outside once there was no chance of frost. The seeds start sprouting once it’s warm enough. The growth of a plant is measured in percentage of its size and plants grow faster on days where the temperature is is warmer. For example, her plant might grow 5%in a day at temperature that’s on the cool side, but 20%in a day where the temperature is warmer. She writes an equation describing the seed growth using the variables
\begin{align*} T \amp= \text{ temperature }(^{\circ}\text{F}) \sim \text{ indep}\\ G \amp= \text{ daily growth rate }(\%) \sim \text{ dep} \end{align*}
Her equation is
\begin{equation*} G = \left\{ \begin{array}{cl}0 \amp \text{if } 0 \le T \le 50 \\ 5(T-50) \amp \text{if } T\gt 50\end{array} \right. \end{equation*}

(a)

At what temperature do Tensia’s seeds sprout? Hint: That would mean the growth is greater than 0.

(b)

By what percentage do Tensia’s seeds grow each day when the temperature is \(60^{\circ}\) F? \(75^{\circ}\) F?

(c)

Is there a jump in the graph? Hint: what would the equation \(G=5(T-50)\) give when \(T=50\text{?}\)

6.

Pachak is boiling water to make some ramen noodles. He fills the pot with a couple of cups of cold tap water which is \(15^{\circ}\text{C}\) (about \(60^{\circ}\text{F}\) ). Next, he sets the pot on the stove and turns on the burner. The burner adds thermal energy measured in kilojoules (kJ) to the water. For every kilojoule of heat the water absorbs, its temperature rises by about \(0.8^{\circ}\text{C}\) until it hits \(100^{\circ}\text{C}\) (or \(212^{\circ}\text{F}\) ). After that, any extra energy goes into turning the boiling water into steam instead of making the water any hotter. The variables in this story are
\begin{align*} E \amp= \text{ energy from the burner (kJ)}\sim \text{ indep}\\ T \amp= \text{ temperature of water }(^{\circ} \text{C}) \sim \text{ dep} \end{align*}
(It’s not important for our story, but in case you’re curious a typical high burner emits about 2 kJ/second, so it would emit 30 kJ after 15 seconds, 60 kJ after 30 seconds, and 120 kJ after 1 minute.)

(a)

Write the linear equation that describes how the temperature of the water depends on the energy from the burner, for temperatures below boiling.

(b)

According to your equation, what is the temperature of the water the burner has emitted 30kJ? After 60 kJ?

(c)

What does the equation say the temperature of the water is after the burner has emitted 120kJ of energy? Why is this temperature incorrect?

(d)

At what energy level does the water boil? Hint: Solve your equation from (a) when \(T=100\text{.}\)

(e)

Write the constant equation that describes the temperature of the water once it’s reached the energy level you found in (d).

(f)

Write a piecewise-linear equation that describes how the temperature of the water depends on the energy from the burner.

(g)

Graph the function, including values up to at least 120kJ of energy.