Skip to main content
\( \newcommand{\lt}{ < } \newcommand{\gt}{ > } \newcommand{\amp}{ & } \)

Section2.8Composition of Functions

Subsection2.8.1Overview

Composition of functions occurs when the output of one function is the input to another function. In the context of variables, this means that the system has a state with three or more variables. Each function defines a relation between two of the variables. Suppose \(f : x \mapsto y\) and \(g : y \mapsto z\). This means that \(x\) and \(z\) are also related. The function that relates them is called the composition, \(g \circ f : x \mapsto z\).

This section introduces the terminology of chains to describe relationships between more than two variables and the ideas of composition of functions. We use composition whenever we use an expression for the input of a function instead of a simple variable. That is, composition is really a generalization of substitution. Learning how to identify composition will also be important in calculus in relation to the chain rule of differentiation.

Subsection2.8.2Functions as Operations

Before proceeding to the actual discussion of composition, I first want to be sure that you have seen the idea that a function can be thought of as a single operation even if it might internally be defined as a many operations brought together.

Example2.8.1

Consider the function \(f : x \mapsto y = f(x)=2x-5\). The function itself contains two operations: multiply by 2 and subtract 5. However, we think of the function \(f\) as a single operation that takes a number \(x\) (whatever its value) and returns a new number which has the related value \(2x-5\). Even though our usual steps of computation to arrive at \(2x-5\) requires two operations, the function accomplishes this in a single step. It is like a specialized mathematics machine whose sole task is to accomplish this operation.

<<SVG image is unavailable, or your browser cannot render it>>

The idea of composition of functions is to take the operations associated with two functions and combine them in sequence to form a new function. This new function, called the composition, has as its operation the consecutive application of the more elementary functions.

Example2.8.2

Returning to our example \(f(x)=2x-5\), we might think of our formula as a composition. Introduce \(u\) as the intermediate value \(u=2x\) and define the following functions: \begin{gather*} \mathrm{mult}_2 : x \mapsto u = 2x,\\ \mathrm{subt}_5 : u \mapsto y = u-5. \end{gather*} The first function \(\mathrm{mult}_2\) has an operation that doubles the value of its input. The second function \(\mathrm{subt}_5\) has an operation that subtracts 5 from its input. The function \(f\) is the composition of these two more elementary functions, illustrated by the map diagram below.

<<SVG image is unavailable, or your browser cannot render it>>

Subsection2.8.3Chains of Variables

It is often the case that more than two variables are related in a predictive way. Consider, for example, a balloon filling with air. To keep the model simple, assume the balloon is always a sphere but with a changing radius. The radius \(r\) and volume \(V\) of the balloon are related through the equation for volume of a sphere, \begin{equation*}V = \frac{4}{3} \pi r^3.\end{equation*} Notice that this equation is written with the dependent variable \(V\) as an explicit function of the independent variable \(r\). By solving for \(r\), we can also write \(r\) as an explicit function of \(V\). \begin{align*} V &= \frac{4}{3} \pi r^3\qquad \hbox{(Multiply by 3)} \\ 3V &= 4 \pi r^3 \qquad \hbox{(Divide by $4 \pi$)} \\ r^3 &= \frac{3V}{4 \pi} \qquad \hbox{(Inverse equation: cube root)} \\ r &= \sqrt[3]{\frac{3V}{4 \pi}} \end{align*} In this new equation, we have the dependent variable \(r\) as a function of the independent variable \(V\).

Now, suppose that we knew how the volume changed as a function of time (based on how much air has been added). Knowing the time \(t\), we can predict the volume \(V\); and knowing the volume \(V\), we can predict the radius \(r\). We will call this idea a chain of dependent variables, \begin{equation*}t \mapsto V \mapsto r.\end{equation*} Consequently, we can think of the final variable \(r\) as a function of the first \(t\) by this chain. This is a composition.

Example2.8.3

A drop of water sitting on a flat surface forms the shape of half a sphere. Suppose the radius of the drop, which starts at 3 mm, is decreasing through evaporation at a rate of 0.2 mm/min. Find the volume of the water as a function of time.

Solution
Example2.8.4

Planting trees is recognized as a method to reduce the amount of carbon dioxide in the atmosphere, with an estimate of about 410 kg of \(\mathrm{CO}_2\) sequestered per tree planted. Suppose that an environmental society begins a campaign to plant 200 trees per year. Express the amount of sequestered \(\mathrm{CO}_2\) as a result of this campaign as a function of time.

Solution

Subsection2.8.4Function Composition

Function composition is where the output to one function is used as the input to the other function.

Definition2.8.5

Let \(f\) and \(g\) be two functions. We define the composition \(g \circ f\) to be a new function \begin{equation*} x \mapsto g \circ f(x) = g(f(x)). \end{equation*} The domain of \(g \circ f\) is the subset of \(\mathrm{dom}(f)\) for which \(f(x)\) is in the domain of \(g\), \begin{equation*} \mathrm{dom}(g \circ f) = \{ x : x \in \mathrm{dom}(f), f(x) \in \mathrm{dom}(g) \}.\end{equation*} The range of \(g \circ f\) is a subset of the range of \(g\).

Notice that the order of the functions in the composition matters because functions are evaluated from the inside out. In the notation \(g \circ f\), the right-most function is the inner-function and the left-most function is the outer-function. To see the connection between function composition and a chain of variables, we think of each function as one step in the chain, with the inner function as the first step and the outer function as the last step.

Example2.8.6

Suppose \(\displaystyle f(x)=\frac{x}{x+1}\) and \(\displaystyle g(x) = 5e^{-x}.\) Find the compositions \(f \circ g(x)\) and \(g \circ f(x)\).

Solution

The previous example illustrated that the order of the composition was important. Doing the composition in the wrong order will not give the same result. In modeling situations, composition almost always arises in the context of a chain of variables where changing the order doesn't even make physical sense.

It is also important to be able to recognize a complex function as a composition of more basic mathematical functions. I recommend looking for a possible chain of calculations as a method for finding the composition.

Example2.8.7

Express \(f(x)=(x^2-3)^4\) as a composition.

Solution
Example2.8.8

For each of the functions, decide if it involves a composition with \(g(x)=x^2\). If so, what is that composition?

  1. \(\displaystyle f(x)=\frac{1}{x^2}\)
  2. \(\displaystyle f(x)= 3 \sin^2(\pi x)=3 \big(\sin(\pi x)\big)^2 \)
  3. \(\displaystyle f(x)=x e^{-x^2}\)
Solution