Unit 3 · Topic 3.1

Differentiate a composition

Builds on the definition of the derivative and the basic derivative rules. 12 minutes.

  1. Example 1Identify the layers of a composition
  2. Example 2Apply the chain rule completely
  3. Example 3Use the chain rule with a table
  4. Example 4Use a composite derivative in context

A composition applies one function to the output of another. If a function \(g\) acts on \(x\) first and a function \(f\) then acts on its output, the composition is

\[y=f\big(g(x)\big)\]

Here \(g\) is the inner function and \(f\) is the outer function, the two layers of the composition. Many books write it as \(f\circ g\). The derivative rules so far handle each layer, but not the composition. This topic finds its derivative from the derivatives of the layers.

Inner and outer functions

Three number lines, for x, u and y, one below the other. A box between the first two lines squares x and adds 9, and a box between the last two takes the square root. An orange dot on each line marks the current value, and orange lines run from each dot through the next box to the dot below. At x = 4 the dots are at u = 25 and y = 5.

Figure 1The orange dot on each number line marks the current value of \(x\), of \(u=x^2+9\) or of \(y\). Each box does one step of \(y=\sqrt{x^2+9}\), and orange lines run from each dot through the next box to the dot below.

Figure 1 computes \(y=\sqrt{x^2+9}\) in two steps, with one box for each step and one number line for each value. The first box squares \(x\) and adds 9, which gives \(u=x^2+9\). The second box takes the square root of \(u\), which gives \(y\). When you move the dot on the top line, the dots below it follow. At \(x=4\), the dots show \(u=25\) and \(y=5\).

The box that acts last is the outer function, because its output is the value of the whole expression. To find the layers of a formula, ask which operation you would do last to compute it at a number. That operation is the outer function, and the expression that it acts on is the inner function. The same question about the inner function finds a third layer, if there is one. If the last operation adds, multiplies or divides two expressions, the formula is a sum, product or quotient, and its own rule comes first.

The slopes of the layers multiply

Three graphs side by side. The first shows an inner function u = g of x that rises from left to right and crosses u = 0 at the middle. The second shows an outer function y = f of u shaped like a U, lowest at u = 0. The third shows the composition y = f of g of x, also shaped like a U, lowest at the middle. Each graph has an orange point with its orange tangent line, a small triangle on the tangent, and its slope written in a corner, and faint dashed lines join the three points. A button bends the bottom of the U in f into a corner, where two red half-lines replace the tangent.

Figure 2Each graph has an orange point with its tangent line and slope, and faint dashed lines join the three points. On each tangent, a small triangle has a dashed run and a rise that is green where the graph rises and red where it falls. At a corner, two red half-lines with the two one-sided slopes replace the tangent.

Figure 2 graphs an inner function \(u=g(x)\), an outer function \(y=f(u)\), and their composition \(y=f\big(g(x)\big)\). The orange point on the first graph is at \(x\), and its height is \(u\). The second graph has \(u\) on its horizontal axis, so its point is at that same \(u\). Each graph shows the tangent line at its point and the slope of that line. Move \(x\). At every position, the slope on the third graph is the product of the slopes on the first two. The figure rounds each slope to two decimals, so the product of the first two can differ from the third by up to 0.02.

Each tangent has a small triangle with a dashed horizontal run. On the first graph, the run is a small change \(\Delta x\) in \(x\), and the rise, \(g'(x)\,\Delta x\), is about the change in \(u\). The second graph uses that rise as its run, so its rise, \(f'(u)\,g'(x)\,\Delta x\), is about the change in \(y\). The third triangle has the run of the first and the rise of the second, so the slope of the third graph is about \(f'(u)\,g'(x)\).

To make the argument exact, write \(\Delta u=g(x+\Delta x)-g(x)\) and \(\Delta y=f(u+\Delta u)-f(u)\). Let \(m\) be the slope \(\Delta y/\Delta u\) of the outer graph from \(u\) to \(u+\Delta u\). This slope does not exist when \(\Delta u=0\), which can happen for small \(\Delta x\ne 0\), for example if \(g\) is constant near \(x\). In that case, let \(m=f'(u)\). Then \(\Delta y=m\,\Delta u\) in both cases, by the definition of \(m\) when \(\Delta u\ne 0\) and because both sides are 0 when \(\Delta u=0\). Divide by \(\Delta x\):

\[\frac{\Delta y}{\Delta x}=m\cdot\frac{\Delta u}{\Delta x}\]

Let \(\Delta x\) approach 0. Because \(g\) is differentiable at \(x\), the quotient \(\Delta u/\Delta x\) approaches \(g'(x)\). A differentiable function is continuous, so \(\Delta u\) approaches 0. Because \(f\) is differentiable at \(u\), the difference quotient \(m\) approaches \(f'(u)\) as \(\Delta u\) approaches 0. Its value at \(\Delta u=0\) is also \(f'(u)\), so \(m\) is a continuous function of \(\Delta u\) at \(\Delta u=0\). A limit passes through a function that is continuous at the limiting value, so \(m\) approaches \(f'(u)\) as \(\Delta x\) approaches 0. By the product law for limits, \(\Delta y/\Delta x\) approaches \(f'(u)\,g'(x)\).

The limit of \(\Delta y/\Delta x\) is the derivative of the composition, so the derivative of \(f\big(g(x)\big)\) is \(f'\big(g(x)\big)\,g'(x)\). It is the derivative of the outer function, evaluated at the inner function, times the derivative of the inner function. This result is the chain rule, which some books call the outside-inside rule. In Leibniz notation, \(f'(u)\) is \(dy/du\) and \(g'(x)\) is \(du/dx\), so \(dy/dx\) is their product, with \(dy/du\) evaluated at \(u=g(x)\).

For \(y=\sqrt{x^2+9}\), the outer layer is \(y=\sqrt u=u^{1/2}\), so \(dy/du=\tfrac12u^{-1/2}\) by the power rule. The inner layer is \(u=x^2+9\), so \(du/dx=2x\). With \(dy/du\) evaluated at \(u=x^2+9\), their product is

\[\frac{dy}{dx}=\frac{1}{2\sqrt{x^2+9}}\cdot 2x=\frac{x}{\sqrt{x^2+9}}\]

At \(x=4\), where Figure 1 shows \(u=25\), the two factors are \(\tfrac{1}{10}\) and 8, so \(dy/dx=\tfrac{8}{10}=\tfrac45\).

The argument needs \(f\) to be differentiable at \(u=g(x)\), the input that \(f\) receives, rather than at \(x\). Use the button under Figure 2 to put a corner in the graph of \(f\). Then move the point on the second graph onto the corner. Its tangent splits into two red half-lines with different slopes, and the graph shows “no slope” where its slope was. The derivative \(f'(u)\) does not exist, so the rule has no outer slope to use. In this figure, the third graph also shows two red half-lines, so the composition has no derivative at that \(x\). Without this hypothesis, the rule does not apply, but the composition can still have a derivative. For example, \(|u|\) has a corner at 0, yet \(\big|x^2\big|=x^2\) has the derivative 0 at \(x=0\).

Longer chains, tables and rates

If the inner function is itself a composition, apply the rule to it as well. With \(y=f(u)\), \(u=g(v)\) and \(v=k(x)\), the rule gives \(du/dx=du/dv\cdot dv/dx\), so \(dy/dx\) is the product of \(dy/du\), \(du/dv\) and \(dv/dx\). The derivative has one factor for each layer, and each factor is evaluated at the value that its layer receives.

At one input \(a\), the rule needs three numbers: \(g(a)\), \(g'(a)\) and \(f'\big(g(a)\big)\). The outer derivative is evaluated at the inner value \(g(a)\), not at \(a\). When a table lists \(f\), \(f'\), \(g\) and \(g'\) at a few inputs, read \(g(a)\) and \(g'(a)\) in the row for \(a\). Then read \(f'\) in the row for the input \(g(a)\). If no row has that input, the table cannot give the derivative.

In a context, each derivative is a rate with units. The rate \(dy/du\) is in units of \(y\) per unit of \(u\), and \(du/dx\) is in units of \(u\) per unit of \(x\). In the product, the units of \(u\) cancel, which leaves units of \(y\) per unit of \(x\). The notation looks like a product of fractions in which \(du\) cancels, but each factor is a limit, and only the units cancel. At a given input, evaluate \(dy/du\) at the value that \(u\) has there.

Example 1

Identify the layers of a composition

Let \(p(x)=\sin^2 x\) and \(q(x)=\sin\left(x^2\right)\). Write each function as \(f\big(g(x)\big)\), and name its outer function \(f\) and its inner function \(g\).

Solution

The outer function is the operation that comes last when you compute the function at a number. The notation \(\sin^2 x\) means \((\sin x)^2\). For \(p\) at \(x=\pi/6\), you first take the sine, \(\sin(\pi/6)=1/2\), and then square it. The square comes last, so

\[f(u)=u^2,\qquad g(x)=\sin x\]

For \(q\) at \(x=3\), you first square, \(3^2=9\), and then take the sine of 9. The sine comes last, so

\[f(u)=\sin u,\qquad g(x)=x^2\]

In each case, \(f\big(g(x)\big)\) is the given function. The same two layers in opposite orders make two different functions. By the chain rule, their derivatives also differ: \(p'(x)=2\sin x\cdot\cos x\), the outer derivative \(2u\) at \(u=\sin x\) times \(\cos x\), and \(q'(x)=\cos\left(x^2\right)\cdot 2x\).

Example 2

Apply the chain rule completely

Let \(y=\ln\left(1+e^{3x}\right)\). Find \(\dfrac{dy}{dx}\) and its value at \(x=0\).

Solution

The exponential and \(3x\) are differentiable everywhere. The logarithm receives \(1+e^{3x}\), which is positive for every \(x\), so it is differentiable at that value. From the outside in, the layers are

\[y=\ln u,\quad u=1+e^{v},\quad v=3x\]

Their derivatives are \(dy/du=1/u\), \(du/dv=e^{v}\) and \(dv/dx=3\). The chain rule multiplies the three, each evaluated at the value its layer receives:

\[\begin{aligned}\frac{dy}{dx}&=\frac{1}{1+e^{3x}}\cdot e^{3x}\cdot 3\\&=\frac{3e^{3x}}{1+e^{3x}}\end{aligned}\]

At \(x=0\), \(e^{0}=1\), so

\[\left.\frac{dy}{dx}\right|_{x=0}=\frac{3\cdot 1}{1+1}=\frac{3}{2}\]

Example 3

Use the chain rule with a table

The table gives values of the differentiable functions \(f\) and \(g\) and their derivatives. Let \(h(x)=f\big(g(x)\big)\). Find \(h'(1)\). \[\begin{array}{c|cccc} x & f(x) & f'(x) & g(x) & g'(x)\\ \hline 1 & 2 & 4 & 3 & -2\\ 2 & 5 & 1 & 1 & -1\\ 3 & 7 & 5 & 0 & 1\\ 4 & 13 & 6 & 2 & 3 \end{array}\]

Solution

Because \(g\) is differentiable at 1 and \(f\) is differentiable at \(g(1)\), the chain rule gives

\[h'(1)=f'\big(g(1)\big)\cdot g'(1)\]

In the row \(x=1\), the table gives the inner value \(g(1)=3\) and the inner derivative \(g'(1)=-2\). The outer function receives 3, so its derivative is read in the row \(x=3\), where \(f'(3)=5\):

\[\begin{aligned}h'(1)&=f'(3)\cdot g'(1)\\&=5\cdot(-2)=-10\end{aligned}\]

Example 4

Use a composite derivative in context

A cube of ice melts so that the length of each edge is \(s=10-0.5t\) centimeters after \(t\) minutes. Its volume is \(V=s^3\) cubic centimeters. Find the rate of change of the volume at \(t=4\), with units.

Solution

Both layers are polynomials, so each is differentiable everywhere. The volume depends on the edge, and the edge depends on time, so in Leibniz notation

\[\frac{dV}{dt}=\frac{dV}{ds}\cdot\frac{ds}{dt}\]

At \(t=4\), the edge is \(s=10-0.5(4)=8\) centimeters, so \(dV/ds=3s^2\) is evaluated at \(s=8\). The edge shrinks at a constant rate:

\[\begin{aligned}\frac{dV}{ds}&=3(8)^2=192\ \text{cm}^3\text{ per cm}\\\frac{ds}{dt}&=-0.5\ \text{cm per min}\end{aligned}\]

In the product, the centimeters of edge cancel:

\[\begin{aligned}\frac{dV}{dt}&=192(-0.5)\\&=-96\ \text{cm}^3\text{ per min}\end{aligned}\]

The rate is negative, so at \(t=4\) the volume decreases at 96 cubic centimeters per minute.

Each example is one of the four skills of topic 3.1 in Which & Why: AP Calculus.