Tutorials › AP Calculus › Why the Second Derivative Chain Rule Has Two Terms

Higher Derivatives and Motion · Tutorial 227 of 999

Why the Second Derivative Chain Rule Has Two Terms

Derive the second derivative chain rule from the product rule and identify the distinct effects represented by its two terms.

Intermediate 9 min read

What You'll Learn

  • Derive the second derivative formula by differentiating the first-derivative chain rule.
  • Explain how the product rule produces two terms.
  • Interpret the role of the outer function’s curvature and the inner function’s changing rate.
  • Identify conditions that make either term vanish at a point.
  • Distinguish a vanishing term from cancellation between nonzero terms.
  • Verify second derivatives by differentiating the original composite function directly.

Why Are There Two Terms?

A composite function changes through two linked processes. The input \(g(x)\) can move through the outer function \(f\), and the rate at which that input moves can itself change. The second derivative records both effects.

The formula for the second derivative of a composite function has two terms. This is not an extra rule to memorize without explanation: the terms appear because the first derivative is a product, and differentiating that product requires the product rule.

Central idea: For \(y=f(g(x))\), the first derivative is \(f'(g(x))g'(x)\). Differentiating this product creates one term from differentiating \(f'(g(x))\) and another from differentiating \(g'(x)\).

The Formula and Its Conditions

Suppose \(f\) is twice differentiable at the relevant inputs and \(g\) is twice differentiable at \(x\). Start with the first derivative chain rule, \(y'=f'(g(x))g'(x)\). Applying the product rule and then the chain rule gives the second derivative.

Theorem: If \(f\) is twice differentiable at \(g(x)\) and \(g\) is twice differentiable at \(x\), then $$ \frac{d^2}{dx^2}f(g(x)) = f''(g(x))\bigl(g'(x)\bigr)^2 + f'(g(x))g''(x). $$

The two terms have different sources. In the first, the outer derivative \(f'\) changes as its input \(g(x)\) changes. In the second, the inner rate \(g'(x)\) changes. Both effects contribute to the change in the first derivative.

Derivation: Differentiate the First Derivative

Let \(y=f(g(x))\). By the chain rule, \(y'=f'(g(x))g'(x)\). This is a product of two factors, so the product rule says to differentiate the first factor while keeping the second fixed, then add the first factor times the derivative of the second.

1
Write the first derivative.
\(y'=f'(g(x))g'(x)\), by the chain rule.
2
Apply the product rule.
\(y''=\frac{d}{dx}[f'(g(x))]g'(x)+f'(g(x))\frac{d}{dx}[g'(x)]\).
3
Differentiate each factor.
The chain rule gives \(\frac{d}{dx}[f'(g(x))]=f''(g(x))g'(x)\), and \(\frac{d}{dx}[g'(x)]=g''(x)\).
4
Substitute and simplify.
\(y''=[f''(g(x))g'(x)]g'(x)+f'(g(x))g''(x)=f''(g(x))(g'(x))^2+f'(g(x))g''(x)\).

This derivation explains both the number of terms and the square on \(g'(x)\). Differentiating \(f'(g(x))\) contributes one factor of \(g'(x)\); the product rule then multiplies that result by the existing \(g'(x)\).

What Each Term Represents

The first term, \(f''(g(x))(g'(x))^2\), measures how the slope of the outer function changes as the inner input moves. The factor \(f''(g(x))\) describes the change in the outer slope with respect to its own input. The squared factor accounts for the inner input’s rate of change entering twice in this part of the calculation.

The second term, \(f'(g(x))g''(x)\), measures how a changing inner rate affects the composite function’s slope. The outer slope \(f'(g(x))\) scales the effect, while \(g''(x)\) describes the change in the inner rate.

These are complementary effects, not two ways of writing the same quantity. A composite function can have one effect without the other, or both effects at once.

Worked Example: A Linear Inner Function

Worked Example: A Linear Inner Function

Find the second derivative of \(y=(2x+1)^3\), using \(f(u)=u^3\) and \(g(x)=2x+1\). Then verify the result by direct differentiation.

First find the derivatives of the component functions:

$$ f'(u)=3u^2,\qquad f''(u)=6u,\qquad g'(x)=2,\qquad g''(x)=0. $$

Substitute into the second derivative chain rule:

$$ \begin{aligned} y'' &=f''(g(x))(g'(x))^2+f'(g(x))g''(x)\\ &=6(2x+1)(2)^2+3(2x+1)^2(0)\\ &=24(2x+1). \end{aligned} $$

For a check, differentiate \(y=(2x+1)^3\) once: \(y'=3(2x+1)^2(2)=6(2x+1)^2\). Differentiate again: \(y''=6\cdot 2(2x+1)\cdot 2=24(2x+1)\), matching the formula.

The second term is zero because \(g''(x)=0\): the inner function has a constant rate of change. The first term remains because the slope of \(u^3\) changes with \(u\).

Worked Example: A Linear Outer Function

Worked Example: A Linear Outer Function

Find the second derivative of \(y=5(x^2+1)-2\), identifying why one of the chain-rule terms vanishes.

Set \(f(u)=5u-2\) and \(g(x)=x^2+1\). Then

$$ f'(u)=5,\qquad f''(u)=0,\qquad g'(x)=2x,\qquad g''(x)=2. $$

Apply the formula:

$$ \begin{aligned} y'' &=f''(g(x))(g'(x))^2+f'(g(x))g''(x)\\ &=0(2x)^2+5(2)\\ &=10. \end{aligned} $$

Check directly by simplifying and differentiating: \(y=5x^2+3\), so \(y'=10x\) and \(y''=10\). This agrees with the result. The first term vanishes because \(f''(u)=0\): a linear outer function has a constant slope. The second term remains because the inner rate \(2x\) changes with \(x\).

Worked Example: Both Terms Contribute

Worked Example: Both Terms Contribute

Find \(y''\) for \(y=e^{x^2+1}\), and evaluate it at \(x=1\).

Choose \(f(u)=e^u\) and \(g(x)=x^2+1\). Since \(f'(u)=f''(u)=e^u\), and \(g'(x)=2x\), \(g''(x)=2\), the formula gives

$$ \begin{aligned} y'' &=e^{x^2+1}(2x)^2+e^{x^2+1}(2)\\ &=e^{x^2+1}(4x^2+2). \end{aligned} $$

At \(x=1\), the inner input is \(g(1)=2\), the inner rate is \(g'(1)=2\), and the inner second derivative is \(g''(1)=2\). Thus the two contributions are

$$ f''(g(1))(g'(1))^2=e^2(2)^2=4e^2,\qquad f'(g(1))g''(1)=e^2(2)=2e^2. $$

Therefore \(y''(1)=4e^2+2e^2=6e^2\). To check, differentiate directly: \(y'=2xe^{x^2+1}\), so \(y''=2e^{x^2+1}+2x\cdot e^{x^2+1}(2x)=e^{x^2+1}(2+4x^2)\). At \(x=1\), this is \(6e^2\), as required.

When Can a Term Vanish?

At a particular input \(x\), the first term vanishes if \(f''(g(x))=0\) or \(g'(x)=0\). The second term vanishes if \(f'(g(x))=0\) or \(g''(x)=0\). These are sufficient conditions for the corresponding product to be zero.

For example, a linear inner function has \(g''(x)=0\), so the second term vanishes wherever that linear function is used. A linear outer function has \(f''(u)=0\), so the first term vanishes. Also, if \(g'(x)=0\) at a point, the first term is zero there, even if \(f''(g(x))\) is not zero.

A term can vanish at one point without vanishing throughout an interval. It is important to distinguish a pointwise fact from a statement about the whole function.

Vanishing Is Not the Same as Cancellation

The two terms can also be nonzero and cancel each other. For instance, let \(f(u)=u^2\) and \(g(x)=1+x-\frac{x^2}{2}\), and examine \(x=0\). Here \(f'(u)=2u\), \(f''(u)=2\), \(g(0)=1\), \(g'(0)=1\), and \(g''(0)=-1\). The terms are

$$ f''(g(0))(g'(0))^2=2(1)^2=2, \qquad f'(g(0))g''(0)=2(1)(-1)=-2. $$

They add to \(y''(0)=0\), even though neither term is zero. Thus, a zero second derivative does not by itself tell you that one of the two effects is absent; the contributions might instead balance at that point.

A Common Mistake

A frequent error is to differentiate \(f'(g(x))g'(x)\) as though only the first factor changes. That drops the contribution from the changing inner rate.

For example, for \(y=e^{x^2+1}\), an incomplete calculation might write \(y''=e^{x^2+1}(2x)^2\), keeping only the term from differentiating \(e^{x^2+1}\). This gives \(4x^2e^{x^2+1}\), which omits \(2e^{x^2+1}\). The correction is to apply the product rule to \(y'=2xe^{x^2+1}\): differentiating \(2x\) contributes \(2e^{x^2+1}\), so \(y''=2e^{x^2+1}+4x^2e^{x^2+1}\).

Check before simplifying: Write both product-rule contributions before substituting or combining factors. If the inner function has a nonzero second derivative, check whether the term \(f'(g(x))g''(x)\) has been included.

Why the Two-Term Structure Matters

The formula helps explain why a composite function can have a changing slope for more than one reason. Even if the inner function moves at a constant rate, the outer function’s slope may change as the input moves through it. And even if the outer function’s slope is constant, a changing inner rate can still make the composite slope change.

For AP Calculus problems, the practical lesson is to keep the structure visible: identify \(f\) and \(g\), find their first and second derivatives, substitute each into its own term, and check for zero factors only after both terms are written. Directly differentiating the first derivative is a useful verification when the expressions are manageable.

Check Your Understanding

For each question, identify the two contributions rather than treating the formula as a single undivided expression.

  1. State the second derivative chain rule for \(y=f(g(x))\), including the conditions needed for the derivatives.
  2. Explain why differentiating \(f'(g(x))\) introduces a factor of \(g'(x)\).
  3. For \(y=f(3x-4)\), which term vanishes, and what property of the inner function makes it vanish?
  4. At a point where \(f''(g(x))=0\), must \(y''\) be zero? Explain using the two-term formula.
  5. Can \(y''(x)=0\) even when neither term in the formula is zero? Give the reason.

Test yourself: AP Calculus practice exams

Ready to check what you know? Work an AP-style practice exam, then open the full solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers all of AP Calculus AB & BC: full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon