The Chain Rule

The chain rule differentiates nested (composite) functions $f(g(x))$: $\big(f(g(x))\big)' = f'(g(x))\cdot g'(x)$ – the derivative of the outer function, evaluated at the inner function, times the derivative of the inner function.

📜 Chain rule formula

$$ \frac{d}{dx}\,f\big(g(x)\big) = f'\big(g(x)\big)\cdot g'(x) $$

Leibniz notation with $y = f(u)$ and $u = g(x)$:

$$ \frac{dy}{dx} = \frac{dy}{du}\cdot\frac{du}{dx} $$

Short form: outer derivative × inner derivative. In the Leibniz form it looks as if the $du$ "cancels" – a useful way to remember it.

🪜 The chain rule in 4 steps

  1. Find the inner function What is "inside"? In $\sin(x^2)$ the inner function is $u = x^2$.
  2. Differentiate the outer function Treat the inside as one block: $(\sin u)' = \cos u$, so $\cos(x^2)$. The inside stays unchanged.
  3. Differentiate the inner function $u' = 2x$.
  4. Multiply $\big(\sin(x^2)\big)' = 2x\cos(x^2)$.

✏️ Worked examples

FunctionOuterInner $u$Derivative
$(3x+2)^5$$u^5$$3x+2$$5(3x+2)^4\cdot 3 = 15(3x+2)^4$
$e^{x^2}$$e^u$$x^2$$2x\,e^{x^2}$
$\sqrt{x^2+1}$$\sqrt{u}$$x^2+1$$\dfrac{2x}{2\sqrt{x^2+1}} = \dfrac{x}{\sqrt{x^2+1}}$
$\ln(4x-1)$$\ln u$$4x-1$$\dfrac{4}{4x-1}$
$\cos(5x)$$\cos u$$5x$$-5\sin(5x)$
$\sin^2 x$$u^2$$\sin x$$2\sin x\cos x$
$\dfrac{1}{(x^2-3)^2}$$u^{-2}$$x^2-3$$-2(x^2-3)^{-3}\cdot 2x = -\dfrac{4x}{(x^2-3)^3}$
$\arctan(2x)$$\arctan u$$2x$$\dfrac{2}{1+4x^2}$

Chain rule and product rule together: $x^2\sin(3x)$

First the product rule, inside it the chain rule for $\sin(3x)$:

$f'(x) = 2x\sin(3x) + 3x^2\cos(3x)$

🪆 Several layers: apply the chain rule repeatedly

For $f(g(h(x)))$ you get one factor per layer – work from the outside in:

$$ \big(f(g(h(x)))\big)' = f'\big(g(h(x))\big)\cdot g'\big(h(x)\big)\cdot h'(x) $$

Example: $\sin^3(2x) = \big(\sin(2x)\big)^3$ has three layers: $3\sin^2(2x)\cdot\cos(2x)\cdot 2$.

$\dfrac{d}{dx}\sin^3(2x) = 6\sin^2(2x)\cos(2x)$

Another one: $\ln(\cos(x^2))$ → $\dfrac{1}{\cos(x^2)}\cdot(-\sin(x^2))\cdot 2x = -2x\tan(x^2)$.

⚠️ Common mistakes

Forgetting the inner derivative – the most frequent error: $(e^{3x})' = 3e^{3x}$, not $e^{3x}$.

Changing the inside: in the outer derivative the inner function stays as it is: $(\cos(x^2))' = -\sin(x^2)\cdot 2x$, not $-\sin(2x)$.

Mixing up product and composition: $x\sin x$ is a product (product rule), $\sin(x^2)$ is a composition (chain rule). $\sin x$ alone needs no chain rule – the inner derivative would just be $1$.

🧮 Try it with the step-by-step calculator

Open any of these examples in the calculator to see every single differentiation step:

Or enter your own function on the derivative calculator.

❓ Frequently asked questions

What is the chain rule?

The chain rule is the rule for differentiating composite functions: $\big(f(g(x))\big)' = f'(g(x))\cdot g'(x)$ – outer derivative times inner derivative.

When do you use the chain rule?

Whenever a function is applied to something more complicated than $x$ itself: $\sin(3x)$, $e^{x^2}$, $(2x+1)^7$, $\sqrt{1-x^2}$, $\ln(x^2+1)$.

What is the chain rule in Leibniz notation?

$\frac{dy}{dx} = \frac{dy}{du}\cdot\frac{du}{dx}$ with $y = f(u)$ and $u = g(x)$.

How do you use the chain rule with the product rule?

Apply the product rule first, and use the chain rule wherever one of the factors is itself a composite function. Example: $(x e^{2x})' = e^{2x} + 2x e^{2x}$.

What is the derivative of e^(2x)?

$(e^{2x})' = 2e^{2x}$ – the exponential stays and is multiplied by the inner derivative $2$.