# 1.9: Combining Functions

- Page ID
- 89285

- How can we create new functions by adding, subtracting, multiplying, or dividing given functions?
- What are piecewise functions and what are different ways we can represent them?

In arithmetic, we execute processes where we take two numbers to generate a new number. For example, \(2 + 3 = 5\text{:}\) the number \(5\) results from adding \(2\) and \(3\text{.}\) Similarly, we can multiply two numbers to generate a new one: \(2 \cdot 3 = 6\text{.}\)

We can work similarly with functions. Indeed, we have already seen a sophisticated way to combine two functions to generate a new, related function through composition. If \(g : A \to B\) and \(f : B \to C\text{,}\) then we know there's a new, related function \(f \circ g : A \to C\) defined by the process \((f \circ g)(x) = f(g(x))\text{.}\) Said differently, the new function \(f \circ g\) results from executing \(g\) first, followed by \(f\text{.}\)

Just as we can add, subtract, multiply, and divide numbers, we can also add, subtract, multiply, and divide functions to create a new function from two or more given functions.

Consider the functions \(f\) and \(g\) defined by Table \(\PageIndex{1}\) and functions \(p\) and \(q\) defined by Figure 1.9.2.

\(x\) | 0 | 1 | 2 | 3 | 4 |
---|---|---|---|---|---|

\(f(x)\) | 5 | 10 | 15 | 20 | 25 |

\(g(x)\) | 9 | 5 | 3 | 2 | 3 |

- Let \(h(x) = f(x) + g(x)\text{.}\) Determine \(h(3)\text{.}\)
- Let \(r(x) = p(x) - q(x)\text{.}\) Determine \(r(-1)\) exactly.
- Are there any values of \(x\) for which \(r(x) = 0\text{?}\) If not, explain why; if so, determine all such values, with justification.
- Let \(k(x) = f(x) \cdot g(x)\text{.}\) Determine \(k(0)\text{.}\)
- Let \(s(x) = \frac{p(x)}{q(x)}\text{.}\) Determine \(s(1)\) exactly.
- Are there any values of \(x\) in the interval \(-4 \le x \le 4\) for which \(s(x)\) is not defined? If not, explain why; if so, determine all such values, with justification.

## Arithmetic with functions

In most mathematics up until calculus, the main object we study is *numbers*. We ask questions such as

- “what number(s) form solutions to the equation \(x^2 - 4x - 5 = 0\text{?}\)”
- “what number is the slope of the line \(3x - 4y = 7\text{?}\)”
- “what number is generated as output by the function \(f(x) = \sqrt{x^2 + 1}\) by the input \(x = -2\text{?}\)”

Certainly we also study overall patterns as seen in functions and equations, but this usually occurs through an examination of numbers themselves, and we think of numbers as the main objects being acted upon.

This changes in calculus. In calculus, the fundamental objects being studied are functions themselves. A function is a much more sophisticated mathematical object than a number, in part because a function can be thought of in terms of its graph, which is an infinite collection of ordered pairs of the form \((x,f(x))\text{.}\)

It is often helpful to look at a function's formula and observe algebraic structure. For instance, given the quadratic function

we might benefit from thinking of this as the sum of three simpler functions: the constant function \(c(x) = -7\text{,}\) the linear function \(s(x) = 5x\) that passes through \((0,0)\) with slope \(m = 5\text{,}\) and the concave down basic quadratic function \(w(x) = -3x^2\text{.}\) Indeed, each of the simpler functions \(c\text{,}\) \(s\text{,}\) and \(w\) contribute to making \(q\) be the function that it is. Likewise, if we were interested in the function \(p(x) = (3x^2 + 4)(9 - 2x^2)\text{,}\) it might be natural to think about the two simpler functions \(f(x) = 3x^2 + 4\) and \(g(x) = 9 - 2x^2\) that are being multiplied to produce \(p\text{.}\)

We thus naturally arrive at the ideas of adding, subtracting, multiplying, or dividing two or more functions, and hence introduce the following definitions and notation.

Let \(f\) and \(g\) be functions that share the same domain. Then,

- The sum of \(f\) and \(g\) is the function \(f + g\) defined by \((f+g)(x) = f(x) + g(x)\text{.}\)
- The difference of \(f\) and \(g\) is the function \(f - g\) defined by \((f-g)(x) = f(x) - g(x)\text{.}\)
- The product of \(f\) and \(g\) is the function \(f \cdot g\) defined by \((f \cdot g)(x) = f(x) \cdot g(x)\text{.}\)
- The quotient of \(f\) and \(g\) is the function \(\frac{f}{g}\) defined by \(\left( \frac{f}{g} \right)(x) = \frac{f(x)}{g(x)}\) for all \(x\) such that \(g(x) \ne 0\text{.}\)

Consider the functions \(f\) and \(g\) defined by **Figure \(\PageIndex{4}\)** and **Figure \(\PageIndex{5}\)**

- Determine the exact value of \((f+g)(0)\text{.}\)
- Determine the exact value of \((g-f)(1)\text{.}\)
- Determine the exact value of \((f \cdot g)(-1)\text{.}\)
- Are there any values of \(x\) for which \(\left( \frac{f}{g} \right)(x)\) is undefined? If not, explain why. If so, determine the values and justify your answer.
- For what values of \(x\) is \((f \cdot g)(x) = 0\text{?}\) Why?
- Are there any values of \(x\) for which \((f-g)(x) = 0\text{?}\) Why or why not?

## Combining functions in context

When we work in applied settings with functions that model phenomena in the world around us, it is often useful to think carefully about the units of various quantities. Analyzing units can help us both understand the algebraic structure of functions and the variables involved, as well as assist us in assigning meaning to quantities we compute. We have already seen this with the notion of average rate of change: if a function \(P(t)\) measures the population in a city in year \(t\) and we compute \(AV_{[5, 11]}\text{,}\) then the units on \(AV_{[5, 11]}\) are “people per year,” and the value of \(AV_{[5, 11]}\) is telling us the average rate at which the population changes in people per year on the time interval from year \(5\) to year \(11\text{.}\)

Say that an investor is regularly purchasing stock in a particular company. 1 Let \(N(t)\) represent the number of shares owned on day \(t\text{,}\) where \(t = 0\) represents the first day on which shares were purchased. Let \(S(t)\) give the value of one share of the stock on day \(t\text{;}\) note that the units on \(S(t)\) are dollars per share. How is the total value, \(V(t)\text{,}\) of the held stock on day \(t\) determined?

This example is taken from Section 2.3 of Active Calculus.

Solution. Observe that the units on \(N(t)\) are “shares” and the units on \(S(t)\) are “dollars per share”. Thus when we compute the product

\[ N(t) \, \text{shares} \cdot S(t) \, \text{dollars per share}\text{,} \nonumber \]

it follows that the resulting units are “dollars”, which is the total value of held stock. Hence,

\[ V(t) = N(t) \cdot S(t)\text{.} \nonumber \]

Let \(f\) be a function that measures a car's fuel economy in the following way. Given an input velocity \(v\) in miles per hour, \(f(v)\) is the number of gallons of fuel that the car consumes per mile (i.e., “gallons per mile”). We know that \(f(60) = 0.04\text{.}\)

- What is the meaning of the statement “\(f(60) = 0.04\)” in the context of the problem? That is, what does this say about the car's fuel economy? Write a complete sentence.
- Consider the function \(g(v) = \frac{1}{f(v)}\text{.}\) What is the value of \(g(60)\text{?}\) What are the units on \(g\text{?}\) What does \(g\) measure?
- Consider the function \(h(v) = v \cdot f(v)\text{.}\) What is the value of \(h(60)\text{?}\) What are the units on \(h\text{?}\) What does \(h\) measure?
- Do \(f(60)\text{,}\) \(g(60)\text{,}\) and \(h(60)\) tell us fundamentally different information, or are they all essentially saying the same thing? Explain.
- Suppose we also know that \(f(70) = 0.045\text{.}\) Find the average rate of change of \(f\) on the interval \([60,70]\text{.}\) What are the units on the average rate of change of \(f\text{?}\) What does this quantity measure? Write a complete sentence to explain.

## Piecewise functions

In both abstract and applied settings, we sometimes have to use different formulas on different intervals in order to define a function of interest.

A familiar and important function that is defined *piecewise* is the absolute value function: \(A(x) = |x|\text{.}\) We know that if \(x \ge 0\text{,}\) \(|x| = x\text{,}\) whereas if \(x \lt 0\text{,}\) \(|x| = -x\text{.}\)

The absolute value of a real number, denoted by \(A(x) = |x|\text{,}\) is defined by the rule

\[ A(x) = \begin{cases} -x, & x \lt 0 \\ x, & x \ge 0 \end{cases} \nonumber \]

The absolute value function is one example of a piecewise-defined function. The “bracket” notation in Definition 1.9.7 is how we express which piece of the function applies on which interval. As we can see in Figure 1.9.8, for \(x\) values less than \(0\text{,}\) the function \(y = -x\) applies, whereas for \(x\) greater than or equal to \(0\text{,}\) the rule is determined by \(y = x\text{.}\)

As long as we are careful to make sure that each potential input has one and only one corresponding output, we can define a piecewise function using as many different functions on different intervals as we desire.

In what follows, we work to understand two different piecewise functions entirely by hand based on familiar properties of linear and quadratic functions.

- Consider the function \(p\) defined by the following rule:
\[ p(x) = \begin{cases} -(x+2)^2 + 2, & x \lt 0 \\ \frac{1}{2}(x-2)^2 + 1, & x \ge 0 \end{cases} \nonumber \]
What are the values of \(p(-4)\text{,}\) \(p(-2)\text{,}\) \(p(0)\text{,}\) \(p(2)\text{,}\) and \(p(4)\text{?}\)

- What point is the vertex of the quadratic part of \(p\) that is valid for \(x \lt 0\text{?}\) What point is the vertex of the quadratic part of \(p\) that is valid for \(x \ge 0\text{?}\)
- For what values of \(x\) is \(p(x) = 0\text{?}\) In addition, what is the \(y\)-intercept of \(p\text{?}\)
- Sketch an accurate, labeled graph of \(y = p(x)\) on the axes provided in
**Figure \(\PageIndex{9}\)**

5. For the function \(f\) defined by Figure 1.9.10, determine a piecewise-defined formula for \(f\) that is expressed in bracket notation similar to the definition of \(y = p(x)\) above.

## Summary

- Just as we can generate a new number by adding, subtracting, multiplying, or dividing two given numbers, we can generate a new function by adding, subtracting, multiplying, or dividing two given functions. For instance, if we know formulas, graphs, or tables for functions \(f\) and \(g\) that share the same domain, we can create their product \(p\) according to the rule \(p(x) = (f \cdot g)(x) = f(x) \cdot g(x)\text{.}\)
- A piecewise function is a function whose formula consists of at least two different formulas in such a way that which formula applies depends on where the input falls in the domain. For example, given two functions \(f\) and \(g\) each defined on all real numbers, we can define a new piecewise function \(P\) according to the rule
\[ P(x) = \begin{cases} f(x), & x \lt a \\ g(x), & x \ge a \end{cases} \nonumber \]
This tells us that for any \(x\) to the left of \(a\text{,}\) we use the rule for \(f\text{,}\) whereas for any \(x\) to the right of or equal to \(a\text{,}\) we use the rule for \(g\text{.}\) We can use as many different functions as we want on different intervals, provided the intervals don't overlap.

## Exercises

Let \(r(t) = 2t - 3\) and \(s(t) = 5 - 3t\text{.}\) Determine a formula for each of the following new functions and simplify your result as much as possible.

- \(\displaystyle f(t) = (r+s)(t)\)
- \(\displaystyle g(t) = (\frac{s}{r})(t)\)
- \(\displaystyle h(t) = (r \cdot s)(t)\)
- \(\displaystyle q(t) = (s \circ r)(t)\)
- \(\displaystyle w(t) = r(t-4) + 7\)

Consider the functions \(s\) and \(g\) defined by the graphs in **Figure \(\PageIndex{11}\)** and **Figure \(\PageIndex{12}\)** Assume that to the left and right of the pictured domains, each function continues behaving according to the trends seen in the figures.

- Determine a piecewise formula for the function \(y = s(t)\) that is valid for all real numbers \(t\text{.}\)
- Determine a piecewise formula for the function \(y = g(x)\) that is valid for all real numbers \(x\text{.}\)
- Determine each of the following quantities or explain why they are not defined.
- \(\displaystyle (s \cdot g)(1)\)
- \(\displaystyle (g-s)(3)\)
- \(\displaystyle (s \circ g)(1.5)\)
- \(\displaystyle (g \circ s)(-4)\)

One of the most important principles in the study of changing quantities is found in the relationship between distance, average velocity, and time. For a moving body traveling on a straight-line path at an average rate of \(v\) for a period of time \(t\text{,}\) the distance traveled, \(d\text{,}\) is given by

In the Ironman Triathlon, competitors swim \(2.4\) miles, bike \(112\) miles, and then run a \(26.2\) mile marathon. In the following sequence of questions, we build a piecewise function that models a competitor's location in the race at a given time \(t\text{.}\) To start, we have the following known information.

- She swims at an average rate of \(2.5\) miles per hour throughout the \(2.4\) miles in the water.
- Her transition from swim to bike takes \(3\) minutes (\(0.05\) hours), during which time she doesn't travel any additional distance.
- She bikes at an average rate of \(21\) miles per hour throughout the \(112\) miles of biking.
- Her transition from bike to run takes just over \(2\) minutes (\(0.03\) hours), during which time she doesn't travel any additional distance.
- She runs at an average rate of \(8.5\) miles per hour throughout the marathon.
- In the questions that follow, assume for the purposes of the model that the triathlete swims, bikes, and runs at essentially constant rates (given by the average rates stated above).

- Determine the time the swimmer exits the water. Report your result in hours.
- Likewise, determine the time the athlete gets off her bike, as well as the time she finishes the race.
- List 5 key points in the form (time, distance): when exiting the water, when starting the bike, when finishing the bike, when starting the run, and when finishing the run.
- What is the triathlete's average velocity over the course of the entire race? Is this velocity the average of her swim velocity, bike velocity, and run velocity? Why or why not?
- Determine a piecewise function \(s(t)\) whose value at any given time (in hours) is the triathlete's total distance traveled.
- Sketch a carefully labeled graph of the triathlete's distance traveled as a function of time on the axes provided. Provide clear scale and note key points on the graph.
- Sketch a possible graph of the triathete's
*velocity*, \(V\text{,}\) as a function of time on the righthand axes. Here, too, label key points and provide clear scale. Write several sentences to explain and justify your graph