Skip to main content
\(\newcommand{\dollar}{\$} \DeclareMathOperator{\erf}{erf} \DeclareMathOperator{\arctanh}{arctanh} \newcommand{\lt}{<} \newcommand{\gt}{>} \newcommand{\amp}{&} \)

Section2.5The chain rule

Motivating Questions
  • What is a composite function and how do we recognize its structure algebraically?

  • Given a composite function \(C(x) = f(g(x))\) that is built from differentiable functions \(f\) and \(g\text{,}\) how do we compute \(C'(x)\) in terms of \(f\text{,}\) \(g\text{,}\) \(f'\text{,}\) and \(g'\text{?}\) What is the statement of the Chain Rule?

In addition to learning how to differentiate a variety of basic functions, we have also been developing our ability to understand how to use rules to differentiate certain algebraic combinations of them. For example, we not only know how to take the derivative of \(f(x) = \sin(x)\) and \(g(x) = x^2\text{,}\) but now we can quickly find the derivative of each of the following combinations of \(f\) and \(g\text{:}\)

\begin{equation*} s(x) = 3x^2 - 5\sin(x), \end{equation*} \begin{equation*} p(x) = x^2 \sin(x), \text{and} \end{equation*} \begin{equation*} q(x) = \frac{\sin(x)}{x^2}. \end{equation*}

Finding \(s'\) uses the sum and constant multiple rules, determining \(p'\) requires the product rule, and \(q'\) can be attained with the quotient rule. Again, we note the importance of recognizing the algebraic structure of a given function in order to find its derivative: \(s(x) = 3g(x) - 5f(x)\text{,}\) \(p(x) = g(x) \cdot f(x)\text{,}\) and \(q(x) =\frac{f(x)}{g(x)}.\)

There is one more natural way to algebraically combine basic functions, and that is by composing them. For instance, let's consider the function

\begin{equation*} C(x) = \sin(x^2), \end{equation*}

and observe that any input \(x\) passes through a chain of functions. In particular, in the process that defines the function \(C(x)\text{,}\) \(x\) is first squared, and then the sine of the result is taken. Using an arrow diagram,

\begin{equation*} x \longrightarrow x^2 \longrightarrow \sin(x^2). \end{equation*}

In terms of the elementary functions \(f\) and \(g\text{,}\) we observe that \(x\) is first input in the function \(g\text{,}\) and then the result is used as the input in \(f\text{.}\) Said differently, we can write

\begin{equation*} C(x) = f(g(x)) = \sin(x^2) \end{equation*}

and say that \(C\) is the composition of \(f\) and \(g\text{.}\) We will refer to \(g\text{,}\) the function that is first applied to \(x\text{,}\) as the inner function, while \(f\text{,}\) the function that is applied to the result, is the outer function.

The main question that we answer in the present section is: given a composite function \(C(x) = f(g(x))\) that is built from differentiable functions \(f\) and \(g\text{,}\) how do we compute \(C'(x)\) in terms of \(f\text{,}\) \(g\text{,}\) \(f'\text{,}\) and \(g'\text{?}\) In the same way that the rate of change of a product of two functions, \(p(x) = f(x) \cdot g(x)\text{,}\) depends on the behavior of both \(f\) and \(g\text{,}\) it makes sense intuitively that the rate of change of a composite function \(C(x) = f(g(x))\) will also depend on some combination of \(f\) and \(g\) and their derivatives. The rule that describes how to compute \(C'\) in terms of \(f\) and \(g\) and their derivatives will be called the chain rule.

But before we can learn what the chain rule says and why it works, we first need to be comfortable decomposing composite functions so that we can correctly identify the inner and outer functions, as we did in the example above with \(C(x) = \sin(x^2).\)

Preview Activity2.5.1

For each function given below, identify its fundamental algebraic structure. In particular, is the given function a sum, product, quotient, or composition of basic functions? If the function is a composition of basic functions, state a formula for the inner function \(g\) and the outer function \(f\) so that the overall composite function can be written in the form \(f(g(x))\text{.}\) If the function is a sum, product, or quotient of basic functions, use the appropriate rule to determine its derivative.

  1. \(h(x) = \tan(2^x)\)

  2. \(p(x) = 2^x \tan(x)\)

  3. \(r(x) = (\tan(x))^2\)

  4. \(m(x) = e^{\tan(x)}\)

  5. \(w(x) = \sqrt{x} + \tan(x)\)

  6. \(z(x) = \sqrt{\tan(x)}\)

Subsection2.5.1The chain rule

One of the challenges of differentiating a composite function is that it often cannot be written in an alternate algebraic form. For instance, the function \(C(x) = \sin(x^2)\) cannot be expanded or otherwise rewritten, so it presents no alternate approaches to taking the derivative. But other composite functions can be expanded or simplified, and these present a way to begin to explore how the chain rule might have to work. To that end, we consider two examples of composite functions that present alternate means of finding the derivative.


Let \(f(x) = -4x + 7\) and \(g(x) = 3x - 5\text{.}\) Determine a formula for \(C(x) = f(g(x))\) and compute \(C'(x)\text{.}\) How is \(C'\) related to \(f\) and \(g\) and their derivatives?


From one perspective, Example 2.5.1 may be too elementary. Linear functions are the simplest of all functions, and perhaps composing linear functions (which yields another linear function) does not exemplify the true complexity that is involved with differentiating a composition of more complicated functions. At the same time, we should remember the perspective that any differentiable function is locally linear, so any function with a derivative behaves like a line when viewed up close. From this point of view, the fact that the derivatives of \(f\) and \(g\) are multiplied to find the derivative of their composition turns out to be a key insight.

We now consider a second example involving a nonlinear function to gain further understanding of how differentiating a composite function involves the basic functions that combine to form it.


Let \(C(x) = \sin(2x).\) Use the double angle identity to rewrite \(C\) as a product of basic functions, and use the product rule to find \(C'\text{.}\) Rewrite \(C'\) in the simplest form possible.


So from Example 2.5.2, we see that if \(C(x) = \sin(2x)\text{,}\) then \(C'(x) = 2\cos(2x)\text{.}\) Letting \(g(x) = 2x\) and \(f(x) = \sin(x)\text{,}\) we observe that \(C(x) = f(g(x))\text{.}\) Moreover, with \(g'(x) = 2\) and \(f'(x) = \cos(x)\text{,}\) it follows that we can view the structure of \(C'(x)\) as

\begin{equation*} C'(x) = 2\cos(2x) = g'(x) f'(g(x)). \end{equation*}

In this example, we see that for the composite function \(C(x) = f(g(x))\text{,}\) the derivative \(C'\) is (as in the example involving linear functions) constituted by multiplying the derivatives of \(f\) and \(g\text{,}\) but with the special condition that \(f'\) is evaluated at \(g(x)\text{,}\) rather than at \(x\text{.}\)

It makes sense intuitively that these two quantities are involved in understanding the rate of change of a composite function: if we are considering \(C(x) = f(g(x))\) and asking how fast \(C\) is changing at a given \(x\) value as \(x\) changes, it clearly matters how fast \(g\) is changing at \(x\text{,}\) as well as how fast \(f\) is changing at the value of \(g(x)\text{.}\) It turns out that this structure holds not only for the functions in Examples 2.5.1 and Example 2.5.2, but indeed for all differentiable functions 1  as is stated in the Chain Rule.

Chain Rule

If \(g\) is differentiable at \(x\) and \(f\) is differentiable at \(g(x)\text{,}\) then the composite function \(C\) defined by \(C(x) = f(g(x))\) is differentiable at \(x\) and

\begin{equation*} C'(x) = f'(g(x)) g'(x). \end{equation*}

As with the product and quotient rules, it is often helpful to think verbally about what the chain rule says: “If \(C\) is a composite function defined by an outer function \(f\) and an inner function \(g\text{,}\) then \(C'\) is given by the derivative of the outer function, evaluated at the inner function, times the derivative of the inner function.”

At least initially in working particular examples requiring the chain rule, it can also be helpful to clearly identify the inner function \(g\) and outer function \(f\text{,}\) compute their derivatives individually, and then put all of the pieces together to generate the derivative of the overall composite function. To see what we mean by this, consider the function

\begin{equation*} r(x) = (\tan(x))^2. \end{equation*}

The function \(r\) is composite, with inner function \(g(x) = \tan(x)\) and outer function \(f(x) = x^2\text{.}\) Organizing the key information involving \(f\text{,}\) \(g\text{,}\) and their derivatives, we have

\(f(x) = x^2\) \(g(x) = \tan(x)\)
\(f'(x) = 2x\) \(g'(x) = \sec^2(x)\)
\(f'(g(x)) = 2\tan(x)\)

Applying the chain rule, which tells us that \(r'(x) = f'(g(x)) g'(x)\text{,}\) we find that for \(r(x) = (\tan(x))^2\text{,}\) its derivative is

\begin{equation*} r'(x) = 2\tan(x) \sec^2(x). \end{equation*}

As a side note, we remark that another way to write \(r(x)\) is \(r(x) = \tan^2(x)\text{.}\) Observe that in this format, the composite nature of the function is more implicit, but this is common notation for powers of trigonometric functions: \(\cos^4(x)\text{,}\) \(\sin^5(x)\text{,}\) and \(\sec^2(x)\) are all composite functions, with the outer function a power function and the inner function a trigonometric one.

The chain rule now substantially expands the library of functions we can differentiate, as the following activity demonstrates.


For each function given below, identify an inner function \(g\) and outer function \(f\) to write the function in the form \(f(g(x))\text{.}\) Determine \(f'(x)\text{,}\) \(g'(x)\text{,}\) and \(f'(g(x))\text{,}\) and then apply the chain rule to determine the derivative of the given function.

  1. \(h(x) = \cos(x^4)\)

  2. \(p(x) = \sqrt{ \tan(x) }\)

  3. \(s(x) = 2^{\sin(x)}\)

  4. \(z(x) = \cot^5(x)\)

  5. \(m(x) = (\sec(x) + e^x)^9\)

Subsection2.5.2Using multiple rules simultaneously

The chain rule now joins the sum, constant multiple, product, and quotient rules in our collection of the different techniques for finding the derivative of a function through understanding its algebraic structure and the basic functions that constitute it. It takes substantial practice to get comfortable with navigating multiple rules in a single problem; using proper notation and taking a few extra steps can be particularly helpful as well. We demonstrate with an example and then provide further opportunity for practice in the following activity.


Find a formula for the derivative of \(h(t) = 3^{t^2 + 2t}\sec^4(t)\text{.}\)


For each of the following functions, find the function's derivative. State the rule(s) you use, label relevant derivatives appropriately, and be sure to clearly identify your overall answer.

  1. \(p(r) = 4\sqrt{r^6 + 2e^r}\)

  2. \(m(v) = \sin(v^2) \cos(v^3)\)

  3. \(h(y) = \frac{\cos(10y)}{e^{4y}+1}\)

  4. \(s(z) = 2^{z^2 \sec (z)}\)

  5. \(c(x) = \sin(e^{x^2})\)

The chain rule now adds substantially to our ability to do different familiar problems that involve derivatives. Whether finding the equation of the tangent line to a curve, the instantaneous velocity of a moving particle, or the instantaneous rate of change of a certain quantity, if the function under consideration involves a composition of other functions, the chain rule is indispensable.


Use known derivative rules, including the chain rule, as needed to answer each of the following questions.

  1. Find an equation for the tangent line to the curve \(y= \sqrt{e^x + 3}\) at the point where \(x=0\text{.}\)

  2. If \(\displaystyle s(t) = \frac{1}{(t^2+1)^3}\) represents the position function of a particle moving horizontally along an axis at time \(t\) (where \(s\) is measured in inches and \(t\) in seconds), find the particle's instantaneous velocity at \(t=1\text{.}\) Is the particle moving to the left or right at that instant?

  3. At sea level, air pressure is 30 inches of mercury. At an altitude of \(h\) feet above sea level, the air pressure, \(P\text{,}\) in inches of mercury, is given by the function \(P = 30 e^{-0.0000323 h}\text{.}\) Compute \(dP/dh\) and explain what this derivative function tells you about air pressure, including a discussion of the units on \(dP/dh\text{.}\) In addition, determine how fast the air pressure is changing for a pilot of a small plane passing through an altitude of \(1000\) feet.

  4. Suppose that \(f(x)\) and \(g(x)\) are differentiable functions and that the following information about them is known:

    \(x\) \(f(x)\) \(f'(x)\) \(g(x)\) \(g'(x)\)
    \(-1\) \(2\) \(-5\) \(-3\) \(4\)
    \(2\) \(-3\) \(4\) \(-1\) \(2\)
    Table2.5.4Data for functions \(f\) and \(g\text{.}\)
    If \(C(x)\) is a function given by the formula \(f(g(x))\text{,}\) determine \(C'(2)\text{.}\) In addition, if \(D(x)\) is the function \(f(f(x))\text{,}\) find \(D'(-1)\text{.}\)

Subsection2.5.3The composite version of basic function rules

As we gain more experience with differentiating complicated functions, we will become more comfortable in the process of simply writing down the derivative without taking multiple steps. We demonstrate part of this perspective here by showing how we can find a composite rule that corresponds to two of our basic functions. For instance, we know that \(\frac{d}{dx}[\sin(x)] = \cos(x)\text{.}\) If we instead want to know

\begin{equation*} \frac{d}{dx}[\sin(u(x))], \end{equation*}

where \(u\) is a differentiable function of \(x\text{,}\) then this requires the chain rule with the sine function as the outer function. Applying the chain rule,

\begin{equation*} \frac{d}{dx}[\sin(u(x))] = \cos(u(x)) \cdot u'(x). \end{equation*}

Similarly, since \(\frac{d}{dx}[a^x] = a^x \ln(a)\text{,}\) it follows by the chain rule that

\begin{equation*} \frac{d}{dx}[a^{u(x)}] = a^{u(x)} \ln(a) \cdot u'(x). \end{equation*}

In the process of getting comfortable with derivative rules, an excellent exercise is to write down a list of all basic functions whose derivatives are known, list those derivatives, and then write the corresponding chain rule for the composite version with the inner function being an unknown function \(u(x)\) and the outer function being the known basic function. These versions of the chain rule are particularly simple when the inner function is linear, since the derivative of a linear function is a constant. For instance,

\begin{equation*} \frac{d}{dx} \left[ (5x+7)^{10} \right] = 10(5x+7)^9 \cdot 5, \end{equation*} \begin{equation*} \frac{d}{dx} \left[ \tan(17x) \right] = 17\sec^2(17x), \ \text{and} \end{equation*} \begin{equation*} \frac{d}{dx} \left[ e^{-3x} \right] = -3e^{-3x}. \end{equation*}


  • A composite function is one where the input variable \(x\) first passes through one function, and then the resulting output passes through another. For example, the function \(h(x) = 2^{\sin(x)}\) is composite since \(x \longrightarrow \sin(x) \longrightarrow 2^{\sin(x)}.\)

  • Given a composite function \(C(x) = f(g(x))\) that is built from differentiable functions \(f\) and \(g\text{,}\) the chain rule tells us that we compute \(C'(x)\) in terms of \(f\text{,}\) \(g\text{,}\) \(f'\text{,}\) and \(g'\) according to the formula

    \begin{equation*} C'(x) = f'(g(x)) g'(x). \end{equation*}



Consider the basic functions \(f(x) = x^3\) and \(g(x) = \sin(x)\text{.}\)

  1. Let \(h(x) = f(g(x))\text{.}\) Find the exact instantaneous rate of change of \(h\) at the point where \(x = \frac{\pi}{4}.\)

  2. Which function is changing most rapidly at \(x = 0.25\text{:}\) \(h(x) = f(g(x))\) or \(r(x) = g(f(x))\text{?}\) Why?

  3. Let \(h(x) = f(g(x))\) and \(r(x) = g(f(x))\text{.}\) Which of these functions has a derivative that is periodic? Why?


Let \(u(x)\) be a differentiable function. For each of the following functions, determine the derivative. Each response will involve \(u\) and/or \(u'\text{.}\)

  1. \(p(x) = e^{u(x)}\)

  2. \(q(x) = u(e^x)\)

  3. \(r(x) = \cot(u(x))\)

  4. \(s(x) = u(\cot(x))\)

  5. \(a(x) = u(x^4)\)

  6. \(b(x) = u^4(x)\)


Let functions \(p\) and \(q\) be the piecewise linear functions given by their respective graphs in Figure 2.5.5. Use the graphs to answer the following questions.

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

Figure2.5.5The graphs of \(p\) (in blue) and \(q\) (in green).

  1. Let \(C(x) = p(q(x))\text{.}\) Determine \(C'(0)\) and \(C'(3)\text{.}\)

  2. Find a value of \(x\) for which \(C'(x)\) does not exist. Explain your thinking.

  3. Let \(Y(x) = q(q(x))\) and \(Z(x) = q(p(x))\text{.}\) Determine \(Y'(-2)\) and \(Z'(0)\text{.}\)


If a spherical tank of radius 4 feet has \(h\) feet of water present in the tank, then the volume of water in the tank is given by the formula

\begin{equation*} V = \frac{\pi}{3} h^2(12-h). \end{equation*}
  1. At what instantaneous rate is the volume of water in the tank changing with respect to the height of the water at the instant \(h = 1\text{?}\) What are the units on this quantity?

  2. Now suppose that the height of water in the tank is being regulated by an inflow and outflow (e.g., a faucet and a drain) so that the height of the water at time \(t\) is given by the rule \(h(t) = \sin(\pi t) + 1\text{,}\) where \(t\) is measured in hours (and \(h\) is still measured in feet). At what rate is the height of the water changing with respect to time at the instant \(t = 2\text{?}\)

  3. Continuing under the assumptions in (b), at what instantaneous rate is the volume of water in the tank changing with respect to time at the instant \(t = 2\text{?}\)

  4. What are the main differences between the rates found in (a) and (c)? Include a discussion of the relevant units.