calculus

The Chain Rule: When and How to Apply It (with Examples)

Master the chain rule with seven worked examples covering trig, exponential, and nested compositions. Learn the outer-then-inner pattern and avoid the most common mistakes.
AI-Math Editorial Team

By AI-Math Editorial Team

Published 2026-05-02

The chain rule is the single most-used tool in differentiation, and also the single biggest source of mistakes. Once you internalise the "outer-then-inner" pattern, you can differentiate almost any composite function in three lines. This guide shows you the pattern, walks through seven escalating examples, and lists the four mistakes worth memorising in advance.

What the chain rule says

If ff and gg are differentiable, the derivative of the composition f(g(x))f(g(x)) is

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

In words: differentiate the outer function evaluated at the inner, then multiply by the derivative of the inner. The "outer" and "inner" labels are non-negotiable — confusing them flips the answer.

A useful mnemonic: the chain rule is "the outer derivative times the inner derivative", never plus, never just one.

Worked examples (easy → hard)

Example 1: ddxsin(2x)\frac{d}{dx}\sin(2x)

  • Outer: sin(u)\sin(u), inner: u=2xu = 2x.
  • ddusin(u)=cos(u)\frac{d}{du}\sin(u) = \cos(u), ddx(2x)=2\frac{d}{dx}(2x) = 2.
  • Result: cos(2x)2=2cos(2x)\cos(2x) \cdot 2 = 2\cos(2x).

Example 2: ddxex2\frac{d}{dx} e^{x^2}

  • Outer: eue^u, inner: u=x2u = x^2.
  • ddueu=eu\frac{d}{du} e^u = e^u, ddx(x2)=2x\frac{d}{dx}(x^2) = 2x.
  • Result: ex22x=2xex2e^{x^2} \cdot 2x = 2x e^{x^2}.

Example 3: ddx(3x2+1)4\frac{d}{dx}(3x^2 + 1)^4

  • Outer: u4u^4, inner: u=3x2+1u = 3x^2 + 1.
  • dduu4=4u3\frac{d}{du} u^4 = 4u^3, ddx(3x2+1)=6x\frac{d}{dx}(3x^2 + 1) = 6x.
  • Result: 4(3x2+1)36x=24x(3x2+1)34(3x^2 + 1)^3 \cdot 6x = 24x(3x^2 + 1)^3.

Example 4: ddxln(cosx)\frac{d}{dx}\ln(\cos x)

  • Outer: lnu\ln u, inner: u=cosxu = \cos x.
  • ddulnu=1u\frac{d}{du}\ln u = \frac{1}{u}, ddxcosx=sinx\frac{d}{dx}\cos x = -\sin x.
  • Result: 1cosx(sinx)=tanx\frac{1}{\cos x} \cdot (-\sin x) = -\tan x.

Example 5: ddxx2+1\frac{d}{dx}\sqrt{x^2 + 1}

  • Rewrite as (x2+1)1/2(x^2 + 1)^{1/2}.
  • Outer: u1/2u^{1/2}, inner: u=x2+1u = x^2 + 1.
  • Outer derivative: 12u1/2\frac{1}{2}u^{-1/2}. Inner: 2x2x.
  • Result: 12(x2+1)1/22x=xx2+1\frac{1}{2}(x^2+1)^{-1/2} \cdot 2x = \frac{x}{\sqrt{x^2+1}}.

Example 6: Nested chain — ddxsin(cos(x2))\frac{d}{dx}\sin(\cos(x^2))

Three layers — apply chain rule twice.

  • Outermost: sin(u)\sin(u), inner u=cos(x2)u = \cos(x^2).
  • dudx=sin(x2)2x\frac{du}{dx} = -\sin(x^2) \cdot 2x (chain rule on cos(x2)\cos(x^2)).
  • Result: cos(cos(x2))(sin(x2))2x=2xsin(x2)cos(cos(x2))\cos(\cos(x^2)) \cdot (-\sin(x^2)) \cdot 2x = -2x\sin(x^2)\cos(\cos(x^2)).

Example 7: Chain + product rule together — ddx(x2sin(3x))\frac{d}{dx}\bigl(x^2 \sin(3x)\bigr)

  • Use the product rule first: (fg)=fg+fg(fg)' = f'g + fg'.
  • f=x2f = x^2, f=2xf' = 2x. g=sin(3x)g = \sin(3x), by chain rule g=3cos(3x)g' = 3\cos(3x).
  • Result: 2xsin(3x)+x23cos(3x)=2xsin(3x)+3x2cos(3x)2x \sin(3x) + x^2 \cdot 3\cos(3x) = 2x\sin(3x) + 3x^2\cos(3x).

The four mistakes worth memorising

  1. Forgetting the inner derivative. Writing ddxsin(2x)=cos(2x)\frac{d}{dx}\sin(2x) = \cos(2x) is the single most common chain-rule error. The factor of 22 is mandatory.
  2. Differentiating the inner before substituting. ddx(3x2+1)4\frac{d}{dx}(3x^2+1)^4 is not 4(6x)34(6x)^3. The outer derivative is evaluated at the inner expression, not at the inner derivative.
  3. Mistaking nested function for product. sin(2x)\sin(2x) is a composition, not a product. Use the chain rule, not the product rule.
  4. Bracketing trig powers wrong. sin2(x)=(sinx)2\sin^2(x) = (\sin x)^2 — outer is u2u^2, inner is sinx\sin x. Easily confused with sin(x2)\sin(x^2) where outer is sin\sin and inner is x2x^2.

When you're stuck: the substitution trick

Set u=(the inner part)u = \text{(the inner part)}, find dydu\frac{dy}{du} and dudx\frac{du}{dx}, multiply. Even when the function looks intimidating, this rote substitution always works.

Try it yourself

Paste any composite function into our free Derivative Calculator and watch each chain-rule application happen step-by-step. Pair it with our chain rule cheat sheet section for quick reference during homework.

For deeper related material:

AI-Math Editorial Team

By AI-Math Editorial Team

Published 2026-05-02

A small team of engineers, mathematicians, and educators behind AI-Math, focused on making step-by-step math help accessible to every student.