Home/Guides/Chain rule
Calculus

How to Use the Chain Rule (With Examples)

The chain rule is for differentiating a function inside another function. Once you can spot which part is "inside," the rest is mechanical — and it's the most-used rule in all of calculus.

When you need it

You need the chain rule whenever the thing you're differentiating is a composition — one function wrapped around another.

The test: if you can point at a piece sitting inside brackets, inside a root, or inside a function, and that piece is anything more complicated than plain x, you need the chain rule.

The rule itself

If y = f(g(x)), then:

dydx = f′(g(x)) · g′(x)

In words, and this is the version worth memorising: differentiate the outside, leave the inside alone, then multiply by the derivative of the inside.

That final multiplication is the entire point of the rule, and it's the part people forget. Nearly every chain rule mistake is some version of dropping the g′(x).

A reliable routine

Before differentiating, write two lines: "outer = …" and "inner = …". It takes five seconds and makes the rest almost impossible to get wrong. You'll skip it after fifty of these — but not before.

Six worked examples

1. A power of something

y = (3x + 1)5

Outer is "something to the fifth," inner is 3x + 1. Differentiate the outside: 5(3x+1)4. Derivative of the inside: 3.

dydx = 5(3x+1)4 · 3 = 15(3x+1)4

2. A trig function of something

y = sin(x²)

Outer is sine, inner is x². Derivative of sine is cosine with the inside untouched: cos(x²). Derivative of the inside: 2x.

dydx = cos(x²) · 2x = 2x cos(x²)

This is not cos(2x). A common slip is differentiating the inside and leaving the result inside the outer function. The inside stays exactly as it was.

3. e to the power of something

y = ex²

The derivative of eu is eu — the outer function is unchanged. Then multiply by the derivative of x²:

dydx = 2x ex²

4. A square root

y = √(x² + 1)

Rewrite the root as a power first, which turns it into an ordinary version of example 1:

y = (x² + 1)1/2
dydx = 12(x²+1)−1/2 · 2x = x√(x²+1)

5. A log of something

y = ln(5x)

The derivative of ln(u) is 1/u, giving 1/(5x). Then multiply by the derivative of 5x, which is 5:

dydx = 15x · 5 = 1x

The 5 cancels entirely — and that's a useful sanity check in itself, since ln(5x) = ln 5 + ln x, and ln 5 is just a constant.

6. A function inside a trig function

y = sin(cos x)
dydx = cos(cos x) · (−sin x) = −sin x cos(cos x)

Don't let the look of it put you off. Outer is sine, inner is cos x. Nothing about the method changes.

Functions inside functions inside functions

With three layers, apply the rule twice — the pattern just extends:

ddx f(g(h(x))) = f′(g(h(x))) · g′(h(x)) · h′(x)

Work strictly outside-in, peeling one layer at a time, and multiply everything at the end. Resist simplifying partway through — finish differentiating first, tidy up second.

Three mistakes that lose marks

All three are catchable. Differentiation is reversible, so if you're unsure, integrate your answer and see whether you land back where you started — or test the original and your derivative numerically at a convenient value like x = 1. More checks like this in how to check if your answer is right.

Practice problems

Differentiate each. Tap to check.

  1. d/dx (5x − 2)4
    Show answer

    20(5x − 2)3

  2. d/dx cos(3x²)
    Show answer

    −6x sin(3x²)

  3. d/dx esin x
    Show answer

    cos x · esin x

  4. d/dx ln(x² + 1)
    Show answer

    2x/(x² + 1)

  5. d/dx √(4 − x²)
    Show answer

    −x/√(4 − x²)

Stuck mid-derivative?

Scan the problem with Aheadia for the full working, step by step — and ask follow-up questions when a line doesn't make sense.

Download free on iOS