Skip to main content

Section 2.3 Chains and Function Composition

Overview.

When we studied how formulas are constructed, we introduced the idea of function composition. Composition occurs whenever a function uses an expression rather than a simple variable as its input. In this section, we study the application of composition in terms of creating a chain of relationships between dependent variables. Given a complex formula that involves composition, we will learn to identify these chains. We will also consider applications of chains using formulas, graphs, and tables.

Subsection 2.3.1 Composition and Chains of Relationships

An algebraic formula typically contains many different operations. If the formula involves a single variable, then that formula could be used to define a function. The function is the map that takes a value for the variable as its input and returns the value of the expression as the output. We could think of the function as a new operation; the formula provides the detailed instructions on how to perform that operation.

Composition occurs whenever the output of one function acts as the input to another function. For example, \(f(x) = (\ln(x))^2\) takes the value of \(x\text{,}\) uses that as the input to \(\ln\text{,}\) the natural logarithm, and then squares the result. This is a composition of the logarithm function with the squaring function. If we introduced the power function \(\mathrm{pow}_2(x) = x^2\text{,}\) then the expression could be rewritten

\begin{equation*} ( \ln(x) )^2 = \mathrm{pow}_2\big( \ln(x) \big)\text{.} \end{equation*}

The parentheses of function notation illustrate that the expression \(\ln(x)\) acts as input to the \(\mathrm{pow}_2\) function.

Because a function should be interpreted as a map between an independent variable and a dependent variable, we can think of function composition as a chain of relationships between more than two variables. In our working example, suppose we introduce the dependent variable \(y = (\ln(x))^2\text{.}\) The calculation involves two steps: first we compute the logarithm, then we square the result. The result of that first operation is an intermediate variable, most commonly chosen as \(u\text{,}\) and we say \(u = \ln(x)\text{.}\) The final operation is an action applied to \(u\text{,}\) namely \(y = u^2\text{.}\) The chain of relationships could be expressed as the system of equations

\begin{equation*} \begin{cases} u = \ln(x), \\ y = u^2. \end{cases} \end{equation*}

The logarithm is used as the map \(x \overset{\ln}{\mapsto} u\) while the squaring function is the map \(u \overset{\mathrm{pow}_2}{\mapsto} y\text{.}\) The overall calculation \(f(x) = (\ln(x))^2\) provides the map \(x \overset{f}{\mapsto} y\text{.}\)

When functions used in a composition are named, a composition operation is represented by a small circle between their names. For our example, we would have \(f(x) = \mathrm{pow}_2 \circ \ln (x)\text{.}\) Because the convention for function notation places the input on the right of the function name (and inside parentheses), the function name on the right of the circle is the inner function that defines the intermediate variable. The function name on the left of the circle is the outer function that completes the calculation.

Many formulas can be interpreted as compositions. To identify a composition, you need to be able to identify that the calculation performs some action on the result of an intermediate expression. However, you need to be careful that you are not using the original independent variable except in the intermediate expression. The intermediate expression itself can appear multiple times. It is often helpful to try to write down a chain of variables to represent the composition. Start by identifying the intermediate expression and assign it to some intermediate variable, such as \(u\text{.}\) This defines the inner function. Then try to write the original expression only in terms of the new variable, substituting every instance of the intermediate expression by your variable. The resulting expression is the outer function.

Example 2.3.1.

Express \(\displaystyle y = \frac{2}{3(x-2)^2+1}\) as a composition.

Solution

There are multiple ways we could express our relation as a composition. We can interpret the order of operations as a sequence of operations acting on the original input \(x\text{.}\)

  1. Take \(x\text{.}\)
  2. Take the value and subtract 2.
  3. Square the result.
  4. Multiply the result by 3.
  5. Take the result and add 1.
  6. Divide 2 by the result.

Because each step in the operation takes the result of all prior steps, we could define the intermediate expression after any of the operations.

Suppose we define the intermediate operation to be all of the steps through squaring the result. Our intermediate variable defines our inner function,

\begin{equation*} u = g(x) = (x-2)^2\text{.} \end{equation*}

The remaining steps in our description describe the outer function.

  1. Take \(u\text{.}\)
  2. Multiply the value by 3.
  3. Take the result and add 1.
  4. Divide 2 by the result.

As an equation, this becomes

\begin{equation*} y = h(u) = \frac{2}{3u+1}\text{,} \end{equation*}

which exactly corresponds to replacing the expression \((x-2)^2\) in the original equation with the intermediate variable \(u\text{.}\) The composition defines the equation

\begin{equation*} y = h \circ g(x)\text{.} \end{equation*}

Choosing a different expression for our intermediate variable results in a different choice for the composition. For example, if we had chosen an inner function to be

\begin{equation*} u = p(x) = x-2\text{,} \end{equation*}

then the outer function would need to be

\begin{equation*} y = r(u) = \frac{2}{3u^2+1}\text{.} \end{equation*}

Thus, we also have \(y = r \circ p(x)\text{.}\) Similarly, if we had chosen

\begin{equation*} u = Q(x) = 3(x-2)^2+1 \end{equation*}

then our outer function would be

\begin{equation*} y = S(u) = \frac{2}{u} \end{equation*}

to give \(y = S \circ Q(x)\text{.}\)

Did you ever have to learn about an algebra topic completing the square? If so, did you find yourself asking the question “Why are we doing this?” One answer could be that a quadratic expression is not written in a way that it can be interpreted as a composition, but after completing the square it is.

Example 2.3.2.

Consider the expression \(x^2+6x-3\text{.}\) The expression is not a composition because it involves addition of two unrelated terms that involve the variable \(x\text{.}\) Completing the square is a strategy where the expression involving only the \(x^2\) and \(x\) terms is recognized as matching the corresponding terms of a squared binomial term. In this case, because \(6 \div 2 = 3\text{,}\) we see that \(x^2+6x-3\) has the same \(x^2\) and \(x\) terms as \((x+3)^2 = x^2 + 6x + 9\text{.}\) Consequently, because we now know that

\begin{equation*} x^2 + 6x = (x+3)^2 - 9\text{,} \end{equation*}

we can write

\begin{equation*} x^2+6x-3 = (x+3)^2 - 12\text{.} \end{equation*}

This new representation expresses our quadratic as the composition of three simple operations: adding 3, squaring, and subtracting 12.

When we are given two functions and compute their composition, we use substitution to simplify our work. It is important to think about inputs and outputs of functions. Function notation is about substitution, using whatever expression appears as the input in place of the independent variable. Be careful that you don't think about multiplying by a function—we apply a function. Otherwise, you are liable to make algebra errors.

Example 2.3.3.

Suppose \(f(x) = 2x^2-1\) and \(g(x) = 2x+5\text{.}\) Compute \(f \circ g(x)\) and \(g \circ f(x)\text{.}\)

Solution

Because function notation has the input on the right, composition places the inner function to the right and the outer function to the left. We start with \(f \circ g(x) = f\big( g(x) \big)\text{.}\) Using the idea of a chain, we have an intermediate variable \(u = g(x) = 2x+5\text{.}\) The composition asks for \(f(u) = 2u^2-1\text{,}\) substituting the independent variable with \(u\text{.}\) When we substitute the inner function in place of \(u\text{,}\) we get

\begin{equation*} f \circ g(x) = f(u) = 2(2x+5)^2 - 1\text{.} \end{equation*}

Notice how the expression replacing \(u\) is placed inside parentheses.

Next, we find \(g \circ f(x)\text{.}\) We now have an intermediate variable \(u = f(x) = 2x^2-1\text{.}\) The outer function then compute \(g(u) = 2u+5\text{.}\) Using substitution, this gives

\begin{equation*} g \circ f(x) = g(u) = 2(2x^2-1) + 5\text{.} \end{equation*}

Once we have our expression using substitution, we could expand and simplify the results:

\begin{align*} f \circ g(x) \amp= 2(2x+5)^2 - 1 = 8x^2 + 40x + 49 \\ g \circ f(x) \amp= 2(2x^2-1)+5 = 4x^2+1 \end{align*}

This example should make it clear that the order of composition is important.

Subsection 2.3.2 Linking Maps through Chains

Composition corresponds to linking functions together, with the output of one function becoming the input to another function. In the context of a physical system, we are considering where the state involves multiple variables, say \((A,B,C,\ldots)\text{.}\) Suppose we know one function, \(f: A \mapsto B\text{,}\) that determines the value of \(B\) knowing the value of \(A\text{.}\) Then suppose know another function, \(g: B \mapsto C\text{,}\) that predicts the value of \(C\) from the value of \(B\text{.}\) If we link these together in a chain, we can start with a value of \(A\text{,}\) compute the value of \(B=f(A)\text{,}\) and then use that value of \(B\) to compute the value of \(C=g(B)\text{.}\) Together, this composition creates a map \(g \circ f : A \mapsto C\text{.}\) Using substitution, we have \(C= g\big(f(A)\big)\text{,}\) the output of \(f\) becoming the input to \(g\text{.}\)

The following dynamic figure allows us to explore how composition links two functions together in a chain. The first (inner) function or map is \(g: x \mapsto u = x+3\text{.}\) The second (outer) function is \(f: u \mapsto y = u^2\text{.}\) As you change the value of the input \(x\text{,}\) you can see where the functions map. The combined action \(f \circ g(x) = (x+3)^2\) represents a single function that is the composition of the steps.

Figure 2.3.4. \(f \circ g(x) = (x+3)^2\)

In the preceding subsection, we looked at composition in terms of formulas. Maps between variables can also be represented in tables and graphs. We can interpret composition by thinking through the relations between variables as we work through the linked maps.

Example 2.3.5.

Suppose \(f\) and \(g\) are functions defined (at least partially) according to the following table. Find each of the following values.

  1. \(f \circ g(2)\)
  2. \(g \circ f(2)\)
  3. \(f \circ f(4)\)
  4. \(g \circ g(0)\)
\(x\) \(f(x)\) \(g(x)\)
-4 2 4
-3 3 1
-2 2 -1
-1 1 -2
0 0 -3
1 -1 0
2 -2 2
3 -3 3
4 -2 4
Solution

When evaluating a function with the table, notice that the columns for \(f(x)\) and \(g(x)\) use an independent variable \(x\text{.}\) This means that we will find the input value in the \(x\) column and then find the corresponding out value in the function's column.

  1. To find \(f \circ g(2)\text{,}\) we expand the substitution \(f \circ g(2) = f \big( g(2) \big)\text{.}\) The inner function is evaluated first to find \(g(2) = 2\text{.}\) That is, we find \(2\) in the column for \(x\) (placeholder for the input), and looking in the column of \(g(x)\) we find 2 as the output. This output is used in the chain linking the function as the input for \(f\text{,}\)

    \begin{equation*} f\big( g(2) \big) = f(2) = -2\text{.} \end{equation*}
  2. To find \(g \circ f(2)\text{,}\) we will expand \(g \circ f(2) = g \big( f(2) \big)\text{.}\) We start with the inner function \(f(2) = -2\text{.}\) We then use the output as the input of the outer function, \(g(-2) = -1\text{.}\) Consequently,

    \begin{equation*} g\big( f(2) \big) = g(-2) = -1\text{.} \end{equation*}
  3. Continuing this pattern, we have

    \begin{equation*} f \circ f(4) = f \big( f(4) \big) = f(-2) = 2\text{.} \end{equation*}
  4. Similarly, we have

    \begin{equation*} g \circ g(0) = g \big( g(0) \big) = g(-3) = 1\text{.} \end{equation*}
Example 2.3.6.

Suppose \(f\) and \(g\) are functions with graphs as shown below. Find each of the following values.

  1. \(f \circ g(2)\)
  2. \(g \circ f(2)\)
  3. \(f \circ f(2)\)
  4. \(f \circ g \circ g(0)\)
Graph of y=f(x)
Graph of y=g(x)
Solution

To evaluate a function when given a graph, we find the value of the input along the \(x\)-axis. This is analogous to looking in the column of \(x\) in a function's table. Once we find the \(x\)-value, we imagine a vertical line at that point and find the point that is included in the graph that intersects our line. If there is no point included in the graph, then the value of \(x\) is not in the domain. For composition, we will use the original input to evaluate the inner function. Once we know the output value, we will use that result when we evalute the outer function.

  1. To evaluate \(f \circ g(2) = f\big( g(2) \big)\text{,}\) we evaluate \(g(2)\) using the graph on the right. The vertical line at \(x=2\) intersects our graph at the point \((2,-1)\text{,}\) so we have \(g(2)=-1\text{.}\) Using that output as the input of \(f\text{,}\) we find \(x=-1\) on the \(x\)-axis of the graph on the left. The vertical line intersects that graph at \((-1,3)\) so that \(f(-1)=3\text{.}\) Putting this together gives

    \begin{equation*} f\big( g(2) \big) = f(-1) = 3\text{.} \end{equation*}
  2. When we evaluate \(g \circ f(2)\text{,}\) we repeat the process but with \(f\) as the inner function and \(g\) as the outer function.

    \begin{equation*} g \circ f(2) = g\big( f(2) \big) = g(-3) = 3\text{.} \end{equation*}
  3. When we evaluate \(f \circ f(2)\text{,}\) the same function is used as the inner and outer function. This means that when we find the output \(f(2) = -3\text{,}\) we use the same function to evaluate \(f(-3)=-3\text{.}\) Consequently, we have

    \begin{equation*} f \circ f(2) = f\big( f(2) \big) = f(-3) = -3\text{.} \end{equation*}
  4. When an expression has more than one composition, we proceed through the chain from the inside out. The expression \(f \circ g \circ g(0)\) has an innermost function \(g\text{.}\) The vertical line \(x=0\) intersections the graph of \(g\) at the point \((0,1)\text{.}\) The open points at \((0,0)\) and \((0,2)\) represent end-points of the graph segments immediately to the left and to the right of the point but are not included as actual points. Consequently, \(g(0) = 1\) which is now the input of the next \(g\) operation. We have

    \begin{equation*} f \circ g \circ g(0) = f \circ g(1) = f(2) = -3\text{.} \end{equation*}

Subsection 2.3.3 Applications of Composition

In modeling settings, composition arises in the context of chains of related variables. Whenever we model relationships between variables, we ideally create functions to describe these relations. A chain occurs when we know a relation between, say, \(A\) and \(B\) and another relation between \(B\) and \(C\text{.}\) Each of these relations might be based on observations or experiments. The chain allows us to identify a relation between \(A\) and \(C\text{,}\) even if a direct observation or experiment is not possible or convenient.

Example 2.3.7.

The radius \(r\text{,}\) circumference \(C\text{,}\) and area \(A\) of a circle are all related. The equation \(C=2 \pi r\) defines \(C\) as a function of \(r\) and the equation \(A = \pi r^2\) defines \(A\) as a function of \(r\text{.}\) Use composition to define the function \(C \mapsto A\text{.}\)

Solution

The final output should be area \(A\text{,}\) which we can compute if we know \(r\text{.}\) We can use the relation between \(C\) and \(r\) to solve for \(r\) as a function of \(C\text{.}\) That is, we want to create a composition of \(C \mapsto r\) and \(r \mapsto A\text{.}\)

\begin{gather*} C = 2 \pi r\\ \frac{C}{2 \pi} = r \end{gather*}

This equation defines \(C \mapsto r\text{,}\) so that we have a chain

\begin{align*} r &= \frac{C}{2 \pi},\\ A &= \pi r^2. \end{align*}

Composition corresponds to substitution of \(r\) by its formula,

\begin{equation*} A = \pi r^2 = \pi \Big(\frac{C}{2\pi}\Big)^2 = \frac{\pi C^2}{2^2 \pi^2} = \frac{C^2}{4 \pi}. \end{equation*}
Example 2.3.8.

Suppose you are blowing up a balloon with air. What is the radius of the balloon as a function of time?

Solution

The question is intentionally somewhat vague in order to illustrate the modeling process. Without more information, the question is ill-posed and there is not a clear answer. What simplifying assumptions could we make that will allow us to create a reasonable answer?

  1. What shape is the balloon? We could make a simplifying assumption that it is approximately a sphere.
  2. How fast is air being added? If we pretend to blow air in a balloon, we can time how long each breath takes. With a quick internet search, we can discover the typical amount of air blown per breath.

  3. Keep things steady. It adds complications to the process if we try to account for inhaling between breaths or slowing down because we are tired. Let us replace human breaths blowing up the balloon with a model that would correspond to steady airflow that matches the average rate of filling.

With our assumptions identified, we can start to establish our model using equations. A sphere has a relationship between volume and radius according to the equation \(V = \frac{4}{3} \pi r^3\text{.}\) Because we want the radius \(r\) as the final output variable, we need \(V \mapsto r\) which we find by solving for \(r\text{.}\)

\begin{equation*} r = \sqrt[3]{\frac{3V}{4 \pi}} = \left( \frac{3V}{4\pi} \right)^{1/3}\text{.} \end{equation*}

Our information about filling the balloon will give us a model for \(t \mapsto V\text{.}\) I found a result showing that there is about 1/2 liter of air exhaled in a breath, which corresponds to 500 cm3. With a timer, I approximated that each steady blow takes about 5 seconds, including inhalation to prepare for the next breath. This means that the balloon is gaining 100 cm3s. If air flows at a steady rate, the relation \(t \mapsto V\) is linear and starts at \(V=0\) when \(t=0\text{.}\) This gives us our second function in the chain,

\begin{equation*} V = 100 t\text{.} \end{equation*}

The composition of the chain \(t \mapsto V \mapsto r\) will give us a model for \(t \mapsto r\text{,}\) which we create using substitution:

\begin{equation*} r = \sqrt[3]{\frac{300 t}{4 \pi}} \text{.} \end{equation*}

Our examples have included questions where a function was composed with itself. This actually occurs in practical settings, such as where a function maps from the value of some quantity to the value of the same quantity at a later time.

Example 2.3.9.

A population's growth and decline depend on how the population size relates to its carrying capacity. If the population is below its capacity, then abundance of resources will lead the population to grow. If the population is too large, then physical constraints will cause the population to decline. Mathematical ecologists study possible behaviors for populations through the use of projection functions. A projection function maps the value of the population size at one time to the next observed population size. That is, knowing the size of the population this year, a projection function allows us to predict the population size next year. Composition of the function with itself then allows us to predict two years away.

Suppose the size of a population (in thousands) has been modeled by an annual projection function \(f(x) = 1.6x - 0.32x^2\text{.}\) If the population is currently 400, what will it be next year? in two years? What is the function that projects the population size two years from the present?

Solution

A population of 400 corresponds to a current population value \(x=0.4\) (thousands). The projection function uses this value to predict one year into the future. When we evaluate the function, we find

\begin{equation*} f(0.4) = 1.6(0.4)-0.32(0.4)^2 = 0.5888\text{,} \end{equation*}

corresponding to a population prediction of 588.8. If we use the function again with an input \(x=0.5888\text{,}\) the function will predict one year from next year, or two years away. This gives

\begin{equation*} f(0.5888) = 1.6(0.5888)-0.32(0.5888)^2 \approx 0.83114\text{.} \end{equation*}

The model therefore predicts approximately 589 individuals in one year and 831 individuals the next year. (The calculation stays exact; the interpretation rounds.)

We found the projected population in two years through composition \(f \circ f(0.4) \approx 0.83114\text{.}\) The process of computation would be the same for any current population value \(x\text{.}\) Consequently, we can create a function that projects the population size in two years by computing the composition \(f \circ f(x)\) using substitution.

\begin{align*} f \circ f(x) \amp= f\big( f(x) \big) \\ \amp= f(1.6x-0.32x^2) \\ \amp= 1.6(1.6x-0.32x^2) - 0.32 (1.6x-0.32x^2)^2 \end{align*}

We have replaced each \(x\) in the formula \(1.6x - 0.32x^2\) with the expression \(1.6x - 0.32x^2\text{.}\) We can use a computer to help expand and simplify this algebraic formula,

\begin{equation*} f \circ f(x) = 2.56 x -1.3312 x^2 + 0.32768 x^3 - 0.032768 x^4 \text{.} \end{equation*}

Subsection 2.3.4 Summary

  • A chain of related variables is where knowing \(A\) you can predict \(B\text{,}\) and knowing \(B\) you can predict \(C\text{,}\) and so on. Composition is using \(A\) and the chain to find \(C\text{.}\)
  • Composition \(f \circ g\) is evaluation of the outer function \(f\) with an input using the output of the inner function \(g\text{,}\)
    \begin{equation*} f \circ g(x) = f\big(g(x)\big)\text{.} \end{equation*}
    As maps, if \(g:x \mapsto u\) and \(f:u \mapsto y\text{,}\) then
    \begin{equation*} x \overset{f \circ g}\mapsto y \quad = \quad x \overset{g}\mapsto u \overset{f}\mapsto y. \end{equation*}

Exercises 2.3.5 Exercises

Rewrite each function as a nontrivial composition of two functions. (Nontrivial means that neither function should be the identify function \(x \mapsto x\text{.}\))

1.

\(f(x) = (x^2-4x)^5\)

2.

\(f(x) = \sqrt{3x+1}\)

3.

\(f(x) = 4e^{-x^2}\)

4.

\(f(x) = 2 \sin(3x) + 1\)

5.

\(\displaystyle f(x) = \frac{2}{(e^{x}+1)^2}\)

6.

\(\displaystyle f(x) = \sqrt{x} - \frac{3}{\sqrt{x}}\)

7.

\(\displaystyle f(x) = \sin^2(x) + 4 \sin(x) + 3\)

8.

\(\displaystyle f(x) = \frac{e^{x}-e^{-x}}{e^{x}+e^{-x}}\)

Using the given functions, compute and simplify the expressions listed.

9.

Given \(p(x)=x^2-1\) and \(r(x)=2x+1\text{.}\)

  1. \(p \circ r(x)\)
  2. \(r \circ p(x)\)
  3. \(p \circ p(x)\)
  4. \(r \circ r(x)\)
10.

Given \(k(x)=e^{x}\) and \(h(x)=1-x^2\text{.}\)

  1. \(k \circ h(x)\)
  2. \(h \circ k(x)\)
  3. \(k \circ k(x)\)
11.

Given \(\displaystyle C(x)=\frac{2}{x-3}\) and \(D(x)=e^{1/x}\text{.}\)

  1. \(C \circ D(x)\)
  2. \(D \circ C(x)\)
  3. \(D \circ D(x)\)
12.

Given \(f\) and \(g\) defined by the table below and \(h(x)=2x-1\text{.}\)

\(x\) \(-4\) \(-3\) \(-2\) \(-1\) \(0\) \(1\) \(2\) \(3\) \(4\)
\(f(x)\) \(4\) \(1\) \(2\) \(0\) \(-2\) \(3\) \(-1\) \(-3\) \(-4\)
\(g(x)\) \(2\) \(-2\) \(4\) \(3\) \(-3\) \(-1\) \(0\) \(1\) \(-4\)
  1. \(f \circ g(2)\)
  2. \(g \circ f(-2)\)
  3. \(f \circ f(-2)\)
  4. \(f \circ h(2)\)
  5. \(h \circ g(1)\)
13.

Given \(f\) and \(g\) defined by the graphs below.

Graph of y=f(x)
Graph of y=g(x)
  1. \(f \circ g(3)\)
  2. \(g \circ f(3)\)
  3. \(f \circ g(1)\)
  4. \(g \circ f(1)\)
  5. \(f \circ g(-3.25)\)
  6. \(g \circ f(-1.25)\)

Applications

14.

The perimeter \(P\) and area \(A\) of a square are each functions of the length of the sides \(s\) by \(P=4s\) and \(A=s^2\text{.}\) Find perimeter as a function of area, \(P \mapsto A\text{.}\)

15.

The volume of a sphere is related to the radius of the sphere by the equation \(V = \frac{4}{3} \pi r^3\text{.}\) Suppose the radius is a function of time defined by \(r = 1+2t\text{.}\) Find the volume as a function of time, \(t \mapsto V\text{.}\)

16.

The cost \(C\) of materials for a project depends on the required area \(A\) of materials needed. The unit price is $3.50 per m2. The project involves making two squares, each of them having sides with length \(s\) (meters).

  1. Find \(A \overset{f}{\mapsto} C\text{.}\)
  2. Find \(s \overset{g}{\mapsto} A\text{.}\)
  3. Use composition to find \(s \mapsto C\text{.}\) Is this \(f \circ g\) or \(g \circ f\text{?}\)

  4. How much would a project with \(s=4\) cost? How much area of materials will be required? What function is used for each calculation?

17.

The density of plants (number of plants per square meter) on a plot of land from year to year has been modeled by the projection function \(f(x) = 2.8x - 0.18x^2\text{.}\) The plot in the current year is observed to have 3.50 plants per square meter.

  1. What is the predicted density of plants in one year?
  2. What is the predicted density of plants in two years?
  3. What is the predicted density of plants in three years?
  4. Find the function that predicts the density of plants two years from the present.