Tutorials › AP Calculus › Third and Fourth Derivatives of Composite Functions

Higher Derivatives and Motion · Tutorial 228 of 999

Third and Fourth Derivatives of Composite Functions

Build higher derivatives of composite functions one step at a time, and see why every chain-rule term matters.

Intermediate 9 min read

What You'll Learn

  • Apply the chain rule repeatedly to find third and fourth derivatives of a composition.
  • Use the general formulas involving derivatives of both the outer and inner functions.
  • Track how product-rule differentiation creates additional terms and coefficients.
  • Find higher derivatives of sine and exponential functions with polynomial inputs.
  • Check a fourth derivative by differentiating the third derivative.
  • Identify and correct the error of keeping only the leading chain-rule term.

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.

$$ y'=f'(g(x))g'(x). $$

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.

Setup: Let \(y=f(g(x))\). Assume the functions have the derivatives needed for the formulas in the region being considered. Write \(g',g'',g'''\), and \(g''''\) for the derivatives of the inner function.

The Third-Derivative Formula

Start from the second derivative chain rule:

$$ y''=f''(g)(g')^2+f'(g)g''. $$

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.

$$ \begin{aligned} y''' &= \frac{d}{dx}\left(f''(g)(g')^2\right) + \frac{d}{dx}\left(f'(g)g''\right)\\ &= f'''(g)g'(g')^2+f''(g)\,2g'g'' +f''(g)g'g''+f'(g)g'''\\ &= f'''(g)(g')^3+3f''(g)g'g''+f'(g)g'''. \end{aligned} $$

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.

$$ \begin{aligned} y''''={}&f''''(g)(g')^4 +6f'''(g)(g')^2g'' +3f''(g)(g'')^2\\ &+4f''(g)g'g''' +f'(g)g''''. \end{aligned} $$
Fourth-derivative formula: For \(y=f(g(x))\), the fourth derivative contains five terms. The derivatives of the outer function are evaluated at \(g(x)\), and the derivatives of the inner function are evaluated at \(x\).

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

$$ \begin{aligned} &f'(u)=\cos u,\quad f''(u)=-\sin u,\quad f'''(u)=-\cos u,\quad f''''(u)=\sin u,\\ &g'=2x,\quad g''=2,\quad g'''=0,\quad g''''=0. \end{aligned} $$

Substitute into the third-derivative formula:

$$ \begin{aligned} y''' &=(-\cos(x^2))(2x)^3 +3(-\sin(x^2))(2x)(2) +\cos(x^2)(0)\\ &=-8x^3\cos(x^2)-12x\sin(x^2). \end{aligned} $$

Now substitute into the fourth-derivative formula:

$$ \begin{aligned} y''''={}&\sin(x^2)(2x)^4 +6(-\cos(x^2))(2x)^2(2)\\ &+3(-\sin(x^2))(2)^2 +4(-\cos(x^2))(2x)(0) +\cos(x^2)(0)\\ ={}&16x^4\sin(x^2)-48x^2\cos(x^2)-12\sin(x^2). \end{aligned} $$

For the check, differentiate the stated third derivative. The product rule gives

$$ \begin{aligned} \frac{d}{dx}\left(-8x^3\cos(x^2)\right) &=-24x^2\cos(x^2)+16x^4\sin(x^2),\\ \frac{d}{dx}\left(-12x\sin(x^2)\right) &=-12\sin(x^2)-24x^2\cos(x^2). \end{aligned} $$

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

$$ \begin{aligned} y''' &=e^{x^2}(2x)^3 +3e^{x^2}(2x)(2) +e^{x^2}(0)\\ &=e^{x^2}(8x^3+12x). \end{aligned} $$

The fourth derivative is

$$ \begin{aligned} y''''={}&e^{x^2}(2x)^4 +6e^{x^2}(2x)^2(2) +3e^{x^2}(2)^2\\ &+4e^{x^2}(2x)(0)+e^{x^2}(0)\\ ={}&e^{x^2}(16x^4+48x^2+12). \end{aligned} $$

To check, write \(y'''=e^{x^2}P(x)\), where \(P(x)=8x^3+12x\). Then \(P'(x)=24x^2+12\), and

$$ \begin{aligned} y'''' &=e^{x^2}(2x)P(x)+e^{x^2}P'(x)\\ &=e^{x^2}\left(2x(8x^3+12x)+24x^2+12\right)\\ &=e^{x^2}(16x^4+48x^2+12), \end{aligned} $$

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

$$ g'=3x^2,\qquad g''=6x,\qquad g'''=6,\qquad g''''=0. $$

The third derivative is

$$ \begin{aligned} y''' &=e^{x^3}(3x^2)^3 +3e^{x^3}(3x^2)(6x) +e^{x^3}(6)\\ &=e^{x^3}(27x^6+54x^3+6). \end{aligned} $$

For the fourth derivative, evaluate each term separately:

$$ \begin{aligned} y''''={}&e^{x^3}(3x^2)^4 +6e^{x^3}(3x^2)^2(6x) +3e^{x^3}(6x)^2\\ &+4e^{x^3}(3x^2)(6) +e^{x^3}(0)\\ ={}&e^{x^3}\left(81x^8+324x^5+108x^2+72x^2\right)\\ ={}&e^{x^3}(81x^8+324x^5+180x^2). \end{aligned} $$

Check by differentiating \(e^{x^3}P(x)\), with \(P(x)=27x^6+54x^3+6\). Since \(P'(x)=162x^5+162x^2\),

$$ \begin{aligned} y'''' &=e^{x^3}\left(3x^2P(x)+P'(x)\right)\\ &=e^{x^3}\left(81x^8+162x^5+18x^2 +162x^5+162x^2\right)\\ &=e^{x^3}(81x^8+324x^5+180x^2). \end{aligned} $$

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

$$ y''' \;\text{(incorrect)}= -\cos(x^2)(2x)^3 =-8x^3\cos(x^2). $$

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

$$ y'''=-8x^3\cos(x^2)-12x\sin(x^2). $$

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

1
Name the inner and outer functions.
Write \(y=f(g(x))\) so each derivative can be placed in the right part of the formula.
2
List the needed derivatives.
Find derivatives of \(f\) through order four and of \(g\) through order four, stopping when a derivative becomes zero.
3
Substitute before simplifying.
Write every term in the formula first. This helps prevent lost terms and signs.
4
Combine like terms and check.
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.

  1. For \(y=\cos(x^2)\), list \(g'\), \(g''\), \(g'''\), and \(g''''\) when \(g(x)=x^2\).
  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?
  3. Find the third derivative of \(y=e^{2x}\) using the composition formula.
  4. For \(y=e^{x^3}\), explain why the term \(f'(g)g'''\) in the third derivative is not zero.
  5. What is the main error in replacing the third derivative of a composition by \(f'''(g)(g')^3\) alone?

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