Why Higher Derivatives of a Composition Need Care
A composite function has one function nested inside another. If \(y=f(g(x))\), the chain rule gives its first derivative by multiplying the outer derivative, evaluated at the inner function, by the derivative of the inner function.
For a second derivative, differentiating this product creates two terms. For the third and fourth derivatives, the chain and product rules must be applied repeatedly, so the number of terms grows. The method is systematic: differentiate each existing term, using the product rule whenever factors depend on \(x\).
In the formulas below, \(f^{(k)}\) means the \(k\)th derivative of \(f\). Each occurrence of \(f^{(k)}\) is evaluated at \(g(x)\), even when the argument is not written explicitly. This shorthand keeps the expressions readable without changing their meaning.
The Third-Derivative Formula
Start from the second derivative chain rule:
Differentiate each term. In the first term, both \(f''(g)\) and \((g')^2\) depend on \(x\). In the second, both \(f'(g)\) and \(g''\) depend on \(x\). Applying the chain and product rules gives the full third derivative.
The coefficient \(3\) comes from combining \(2f''(g)g'g''\) and \(f''(g)g'g''\). It is not an extra rule to memorize separately; it results from differentiating the second derivative carefully.
The Fourth-Derivative Formula
Differentiate the three terms in the third-derivative formula. For example, differentiating \(f'''(g)(g')^3\) requires the product rule, and differentiating \(f'''(g)\) also requires the chain rule. Collecting like terms produces the fourth derivative.
The coefficients \(6\), \(3\), and \(4\) account for the different ways the product rule distributes derivatives among the factors. The formula is valid wherever the required derivatives of the composition exist; in particular, the displayed expression uses derivatives of \(f\) through order four and of \(g\) through order four.
Worked Example: Third and Fourth Derivatives of \(\sin(x^2)\)
Worked Example: Third and Fourth Derivatives of \(\sin(x^2)\)
Find the third and fourth derivatives of \(y=\sin(x^2)\), then check the fourth derivative by differentiating the third.
Set \(f(u)=\sin u\) and \(g(x)=x^2\). The needed derivatives are
Substitute into the third-derivative formula:
Now substitute into the fourth-derivative formula:
For the check, differentiate the stated third derivative. The product rule gives
Adding these results gives \(16x^4\sin(x^2)-48x^2\cos(x^2)-12\sin(x^2)\), exactly the fourth derivative found from the formula.
Worked Example: Derivatives of \(e^{x^2}\)
Worked Example: Derivatives of \(e^{x^2}\)
Find the third and fourth derivatives of \(y=e^{x^2}\) and verify the fourth derivative.
Take \(f(u)=e^u\), so \(f'=f''=f'''=f''''=e^u\), and again use \(g=x^2\), with \(g'=2x\), \(g''=2\), and \(g'''=g''''=0\). The third derivative is
The fourth derivative is
To check, write \(y'''=e^{x^2}P(x)\), where \(P(x)=8x^3+12x\). Then \(P'(x)=24x^2+12\), and
which agrees with the formula-based result.
Worked Example: A Cubic Input to an Exponential
Worked Example: A Cubic Input to an Exponential
Find the third and fourth derivatives of \(y=e^{x^3}\). This example has a nonzero third derivative of the inner function, so it uses another term in each formula.
Let \(f(u)=e^u\) and \(g(x)=x^3\). Then \(f^{(k)}(u)=e^u\) for each derivative order used, while
The third derivative is
For the fourth derivative, evaluate each term separately:
Check by differentiating \(e^{x^3}P(x)\), with \(P(x)=27x^6+54x^3+6\). Since \(P'(x)=162x^5+162x^2\),
The independently differentiated result matches the formula.
A Common Mistake: Keeping Only the First Term
A tempting shortcut is to take the third derivative of the outer function and multiply by the inner derivative cubed. That gives only the first term of the third-derivative formula. For \(y=\sin(x^2)\), this mistake produces
This omits \(3f''(g)g'g''\) and \(f'(g)g'''\). Here \(g''=2\), so the missing middle term is \(-12x\sin(x^2)\), and the last term is zero because \(g'''=0\). The correct result is therefore
The error occurs because a higher derivative is not found by applying the chain rule to the outer function alone. At each stage, differentiate every factor already present and account for each product-rule term.
A Reliable Calculation Process
Write \(y=f(g(x))\) so each derivative can be placed in the right part of the formula.
Find derivatives of \(f\) through order four and of \(g\) through order four, stopping when a derivative becomes zero.
Write every term in the formula first. This helps prevent lost terms and signs.
Differentiate the third derivative directly to confirm the fourth derivative.
Why the Formulas Matter
Higher derivatives describe how the rate of change itself changes, but nested functions make that change depend on both the outer function and the inner function. The formulas organize these contributions without requiring a fresh expansion from scratch each time. Their terms also signal why substituting values too early can be risky: terms involving \(g''\), \(g'''\), or \(g''''\) may still contribute even when one particular derivative happens to vanish.
When a calculation becomes long, preserve the structure of the formula until all derivatives have been substituted. Then simplify, and use direct differentiation as a check where practical. This is especially useful for compositions involving polynomials, whose derivatives eventually become zero, while the outer trigonometric or exponential derivatives continue to cycle or repeat.
Check Your Understanding
Use the third- and fourth-derivative formulas to answer each question. Keep the chain-rule and product-rule contributions visible before simplifying.
- For \(y=\cos(x^2)\), list \(g'\), \(g''\), \(g'''\), and \(g''''\) when \(g(x)=x^2\).
- For \(y=f(g(x))\), which term in the third-derivative formula has coefficient \(3\), and what product-rule contributions combine to produce it?
- Find the third derivative of \(y=e^{2x}\) using the composition formula.
- For \(y=e^{x^3}\), explain why the term \(f'(g)g'''\) in the third derivative is not zero.
- What is the main error in replacing the third derivative of a composition by \(f'''(g)(g')^3\) alone?