Step-by-Step Math Tutorials · 4 min read

The chain rule, explained with examples

The chain rule says that the derivative of one function inside another, f(g(x))f(g(x)), is f′(g(x))⋅g′(x)f'(g(x)) \cdot g'(x): differentiate the outside, keep the inside, then multiply by the derivative of the inside. It is the derivative rule students use most and forget most, because the hard part is seeing that a function has an inside at all. This guide shows how to spot one every time.

Diagram of the chain rule on (3x² + 1)⁵: the inside 3x² + 1 is boxed, the outer derivative 5(3x² + 1)⁴ is multiplied by the inside derivative 6x, giving 30x(3x² + 1)⁴.

What the chain rule says

If a function is built by putting one function inside another, f(g(x))f(g(x)), its derivative is the derivative of the outside, evaluated at the inside, times the derivative of the inside:

ddxf(g(x))=f′(g(x))⋅g′(x)\frac{d}{dx}f(g(x)) = f'(g(x)) \cdot g'(x)

In words: differentiate the outside, leave the inside alone, then multiply by the derivative of the inside.

How to spot the inside function

Ask: if I had to calculate this for x = 2, what would I do last? That last step is the outside function. Everything you did before it is the inside.

  • (3x2+1)5(3x^2 + 1)^5: you would compute 3x2+13x^2 + 1 first, then raise it to the 5th. Outside: the 5th power. Inside: 3x2+13x^2 + 1.
  • sin⁡(4x)\sin(4x): compute 4x, then take the sine. Outside: sine. Inside: 4x.
  • cos⁡(x3)\cos(x^3): cube first, then cosine. Outside: cosine. Inside: x3x^3.

If the inside is just x, there is no chain rule — the extra factor would be 1.

Example 1 · A power of a polynomial

ddx(3x2+1)5\frac{d}{dx} (3x^{2} + 1)^{5}
Solve it live

Bring down the 5, keep the bracket, then multiply by 6x.

  1. Differentiate with respect to x
    ddx[(3⋅(x2)+1)5]\frac{d}{dx} [(3 \cdot (x ^ 2) + 1) ^ 5]
    This is the derivative to find.
  2. Apply the power rule
    ddx[x5]=5⋅x5−1\frac{d}{dx}[x^{5}] = 5 \cdot x^{5 - 1}
    Bring the exponent down front, then lower it by one.
  3. Simplify
    30x⋅(3x2+1)430x \cdot (3x^{2}+1)^{4}
    Collect terms for the final answer.
30x⋅(3x2+1)430x \cdot (3x^{2}+1)^{4}
✓ Verified

Example 2 · A linear inside

ddxsin⁡(4x)\frac{d}{dx} \sin(4x)
Solve it live

The inside 4x contributes a factor of 4.

  1. Differentiate with respect to x
    ddx[sin⁡(4⋅x)]\frac{d}{dx} [\sin(4 \cdot x)]
    This is the derivative to find.
  2. Apply the chain rule
    ddx[sin⁡(4⋅x)]=sin′(4⋅x)⋅ddx[4⋅x]\displaystyle \frac{d}{dx}[\sin(4 \cdot x)] = sin'(4 \cdot x) \cdot \frac{d}{dx}[4 \cdot x]
    Differentiate the outer function, then multiply by the derivative of what is inside.
  3. Differentiate the outer and inner parts
    outer: cos⁡((4⋅x)),inner: 4\displaystyle \allowbreak \text{outer: } \cos((4 \cdot x)),\allowbreak \quad \allowbreak \text{inner: } 4
    Handle each layer on its own.
  4. Simplify
    4cos⁡(4x)4\cos(4x)
    Collect terms for the final answer.
4cos⁡(4x)4\cos(4x)
✓ Verified

Example 3 · Trig of a power

ddxcos⁡(x3)\frac{d}{dx} \cos(x^{3})
Solve it live

Cosine differentiates to minus sine; the cube contributes 3x23x^2.

  1. Differentiate with respect to x
    ddx[cos⁡(x3)]\frac{d}{dx} [\cos(x ^ 3)]
    This is the derivative to find.
  2. Apply the chain rule
    ddx[cos⁡(x3)]=cos′(x3)⋅ddx[x3]\displaystyle \frac{d}{dx}[\cos(x ^ 3)] = cos'(x ^ 3) \cdot \frac{d}{dx}[x ^ 3]
    Differentiate the outer function, then multiply by the derivative of what is inside.
  3. Differentiate the outer and inner parts
    outer: −sin⁡((x3)),inner: 3x2\displaystyle \allowbreak \text{outer: } -\sin((x ^ 3)),\allowbreak \quad \allowbreak \text{inner: } 3x^{2}
    Handle each layer on its own.
  4. Simplify
    −3x2sin⁡(x3)-3x^{2}\sin(x^{3})
    Collect terms for the final answer.
−3x2sin⁡(x3)-3x^{2}\sin(x^{3})
✓ Verified

Chains inside products

In real problems the chain rule turns up inside other rules. In x2sin⁡(3x)x^2 \sin(3x), the product rule splits the work, and one of the pieces needs the chain rule. Work one layer at a time and write each piece down before combining them.

The derivative calculator names each rule as it applies it, which is a good way to check you have not skipped a layer. For AP students, the chain rule is the heart of Unit 3 — see the AP Calculus page.

FAQ

Questions about this guide

When do I use the chain rule?

Whenever a function sits inside another function — a bracket raised to a power, a trig function of something other than plain x, e to a power of x, and so on.

What is the most common chain rule mistake?

Forgetting to multiply by the derivative of the inside. Differentiating (3x2+1)5(3x^2+1)^5 as 5(3x2+1)45(3x^2+1)^4 misses the factor 6x.

Can there be more than one chain?

Yes. In sin⁡3(2x)\sin^3(2x) there are three layers: a cube, a sine and 2x. Apply the rule once per layer, from the outside in.

Put the method to work

Try the technique from this guide on a problem of your own — with every step shown and checked.