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.
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.
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.
\(y'=f'(g(x))g'(x)\), by the chain rule.
\(y''=\frac{d}{dx}[f'(g(x))]g'(x)+f'(g(x))\frac{d}{dx}[g'(x)]\).
The chain rule gives \(\frac{d}{dx}[f'(g(x))]=f''(g(x))g'(x)\), and \(\frac{d}{dx}[g'(x)]=g''(x)\).
\(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:
Substitute into the second derivative chain rule:
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
Apply the formula:
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
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
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
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}\).
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.
- State the second derivative chain rule for \(y=f(g(x))\), including the conditions needed for the derivatives.
- Explain why differentiating \(f'(g(x))\) introduces a factor of \(g'(x)\).
- For \(y=f(3x-4)\), which term vanishes, and what property of the inner function makes it vanish?
- At a point where \(f''(g(x))=0\), must \(y''\) be zero? Explain using the two-term formula.
- Can \(y''(x)=0\) even when neither term in the formula is zero? Give the reason.