Chalk−1

Math · Calculus I · Concept

The chain rule for derivatives

The chain rule differentiates a function inside another function, such as sin(x²) or (3x + 1)⁵⁰. Differentiate the outside function while leaving the inside untouched, then multiply by the derivative of the inside: the derivative of f(g(x)) is f′(g(x))·g′(x).

When you need the chain rule

The power, product and quotient rules handle functions that are added, multiplied or divided. The chain rule handles the remaining way to build a function: applying one function to the output of another. This is called composition, and the result is a composite function.

sin(x²) is not sin x times x². The x² sits inside the sine, and none of the other rules can reach it. (3x + 1)⁵⁰ could in principle be expanded into 51 terms, but the chain rule differentiates it in one line. Whenever a function is applied to something more complicated than plain x, the chain rule is involved.

sin(x2)(3⁢x+1)50e−x2x2+1
sin(x2)(3⁢x+1)50e−x2x2+1

Find the inside and the outside

A composite function works in two stages: x goes into the inside function, and the inside’s output goes into the outside function.

To tell which is which, imagine working out the value for one particular x, say x = 2. Whatever you work out first is the inside. The last operation you apply is the outside. For sin(x²), you first square 2 to get 4 and then take the sine, so the inside is x² and the outside is the sine. For (3x + 1)⁵, you first work out 3·2 + 1 = 7 and then raise 7 to the 5th power, so the inside is 3x + 1 and the outside is the 5th power.

Give the inside its own letter, usually u. Writing u = g(x) and y = f(u) splits one complicated function into two simple ones, and each simple one is easy to differentiate.

The inside and the outside of common composite functions
FunctionInside, uOutside, in terms of u
(3x + 1)⁵3x + 1u⁵
sin(x²)x²sin u
sin²x, which means (sin x)²sin xu²
e^(4x)4xeᵘ
√(x² + 1)x² + 1√u
ln(cos x)cos xln u
1/(2x − 5)³2x − 51/u³, which is u⁻³
Composition or product?

In a composition, one function’s output is fed in as the other’s input: in sin(x²), the sine acts on x². In a product, two functions are each worked out from x and then multiplied: in x² sin x, you find x² and sin x separately and multiply the results.

A product needs the product rule. Its factors may still need the chain rule on their own, as in x² sin(3x), where the second factor is a composition.

Why the rates multiply

A derivative is a rate: how many times as fast the output changes as the input. Follow one small change through both stages of y = (3x + 1)², whose inside is u = 3x + 1 and whose outside is y = u².

At x = 1, u = 4 and y = 16. Nudge x up by 0.01. The inside moves to u = 4.03, three times as far as x moved, because du/dx = 3. The outside moves to y = 4.03² = 16.2409, about eight times as far as u moved, because dy/du = 2u, which is 8 when u = 4.

So y moved about 3 × 8 = 24 times as far as x: 0.2409 ÷ 0.01 = 24.09. The exact derivative at x = 1 is 24. Each stage multiplies the change by its own rate, like a pair of gears: if the middle gear turns 3 times as fast as the first, and the last turns 8 times as fast as the middle, then the last turns 24 times as fast as the first.

d⁢yd⁢x=d⁢yd⁢u⋅d⁢ud⁢x=8⋅3=24
Following a nudge of 0.01 through y = (3x + 1)² at x = 1
QuantityAt x = 1At x = 1.01ChangeCompared with the stage before
x11.010.01the nudge
u = 3x + 144.030.033 times the change in x
y = u²1616.24090.2409about 8 times the change in u

The chain rule

Putting the two stages together gives the rule. If y = f(u) and u = g(x), the rate of y with respect to x is the rate of y with respect to u times the rate of u with respect to x.

In words: the derivative of the outside, evaluated at the inside, times the derivative of the inside. “Evaluated at the inside” means you find the outside function’s derivative and then put the whole inside expression where its variable was. f′(g(x)) means f′ applied to g(x). It does not mean f′(x) times g(x).

dd⁢xf⁡(g⁡(x))=f⁡′(g⁡(x))g⁡′(x)
dd⁢xf⁡(g⁡(x))=f⁡′(g⁡(x))g⁡′(x)
Is the chain rule just cancelling du?

No, although Leibniz notation makes it look that way, which is what makes it such a good memory aid. dy/du and du/dx are limits, not fractions.

For an actual small change Δx, the changes do satisfy Δy/Δx = (Δy/Δu)·(Δu/Δx) whenever Δu ≠ 0, and letting Δx shrink to 0 turns the three ratios into the three derivatives. A complete proof must also cover an inside that stops changing near the point, where Δu = 0 and the middle ratio is undefined. It does this by writing each function as its linear approximation plus an error that shrinks faster than the change.

d⁢yd⁢x=d⁢yd⁢u⋅d⁢ud⁢x

The method in five steps

Until the chain rule feels automatic, write every stage down. The table works through y = sin(x²).

The finished derivative contains only x. If a u is still there, the last step isn’t finished.

d⁢yd⁢x=cos(x2)⋅2⁢x=2⁢xcos(x2)
The five steps of the chain rule on y = sin(x²)
StepWhat to doFor y = sin(x²)
1Name the insideu = x²
2Rewrite y using uy = sin u
3Differentiate the outside with respect to udy/du = cos u
4Differentiate the inside with respect to xdu/dx = 2x
5Multiply, then put the inside back in place of udy/dx = cos(x²) · 2x = 2x cos(x²)

The shortcut: copy the inside, then multiply

With practice you can skip the letter u. Differentiate the outside as if the inside were a single letter, copying the inside exactly as it is, then multiply by the derivative of the inside.

For (x² + 5)⁷, the outside is the 7th power, so write 7(x² + 5)⁶ with the inside copied unchanged. The derivative of the inside is 2x. Multiply to get 14x(x² + 5)⁶.

The table lists the patterns you will use most. Each one is the chain rule with a familiar outside function. The square root and logarithm patterns need a positive inside, g(x) > 0.

dd⁢x⁢(x2+5)7=7⁢(x2+5)6⋅2⁢x=14⁢x⁢(x2+5)6
dd⁢x⁢(x2+5)7=7⁢(x2+5)6⋅2⁢x=14⁢x⁢(x2+5)6
Chain rule patterns
FunctionDerivative
[g(x)]ⁿn[g(x)]ⁿ⁻¹ · g′(x)
√g(x)g′(x) / (2√g(x))
e^(g(x))e^(g(x)) · g′(x)
ln g(x)g′(x) / g(x)
sin g(x)cos g(x) · g′(x)
cos g(x)−sin g(x) · g′(x)
tan g(x)sec² g(x) · g′(x)

An inside of kx, or just x

When the inside is a number times x, its derivative is that number, so the chain rule multiplies by it. The derivative of sin(5x) is 5 cos(5x), and the derivative of e^(3x) is 3e^(3x).

The chain rule is at work even when the inside is plain x. The derivative of sin x is cos x times the derivative of x, which is 1, so the extra factor is invisible. That is why the basic rules work without it, and why it appears as soon as the inside is anything other than x.

dd⁢xsin(5⁢x)=5cos(5⁢x)dd⁢xe3⁢x=3e3⁢x
dd⁢xsin(5⁢x)=5cos(5⁢x)dd⁢xe3⁢x=3e3⁢x

Layers inside layers

Some functions have three or more layers. Peel them from the outside in, and write one derivative factor for each layer, copying everything inside that layer unchanged.

In y = sin³(4x), which means (sin 4x)³, the outermost layer is the cube, the middle layer is the sine and the innermost layer is 4x. The cube gives 3 sin²(4x), the sine gives cos(4x), and 4x gives 4. Multiply all three to get 12 sin²(4x) cos(4x).

Count the layers before you start. The number of factors you multiply should match.

dd⁢xsin3(4⁢x)=3sin2(4⁢x)⋅cos(4⁢x)⋅4=12sin2(4⁢x)cos(4⁢x)
dd⁢xsin3(4⁢x)=3sin2(4⁢x)⋅cos(4⁢x)⋅4=12sin2(4⁢x)cos(4⁢x)

Using it with the product and quotient rules

When a problem needs several rules, find the structure at the top level first by asking which operation is done last. In x²e^(3x), you work out x² and e^(3x) separately and then multiply, so the function is a product and the product rule comes first. The chain rule appears inside it, when you differentiate the factor e^(3x).

If the last operation is a function applied to an expression, start with the chain rule instead. In sin(x eˣ), the sine is applied last, so the outside is the sine, and its inside, x eˣ, needs the product rule.

dd⁢x(x2e3⁢x)=2⁢xe3⁢x+x2⋅3e3⁢x=xe3⁢x(2+3⁢x)
dd⁢x(x2e3⁢x)=2⁢xe3⁢x+x2⋅3e3⁢x=xe3⁢x(2+3⁢x)

Check your answer

Three quick checks catch most chain rule mistakes.

Count the factors. A function with two layers needs two factors, and one with three layers needs three.

Try a number. For a small h such as 0.001, the ratio [y(x + h) − y(x)] / h should be close to your derivative at that x.

Differentiate another way when you can. (3x + 1)² expands to 9x² + 6x + 1, and the power rule gives 18x + 6, the same as the chain rule.

In a Math box, write the function as f(x) = … with your derivative below it as f′(x) = …, and the Checker marks the derivative ✓ or ✗. Name the function with the variable its formula uses: for a formula in r, write f(r) and f′(r). Explore on a Math box row, then Differentiate, shows the outside-in steps for a function you type.

Common mistakes

  • Forgetting the derivative of the inside, the most common slip: the derivative of (3x + 1)² is 2(3x + 1)·3 = 18x + 6, not 2(3x + 1).
  • Changing the inside while differentiating the outside: the derivative of sin(x²) is cos(x²)·2x. It is not cos(2x), and it is not cos x·2x; the inside stays exactly as it was.
  • Confusing sin²x with sin(x²): sin²x means (sin x)², whose outside is the square, so its derivative is 2 sin x cos x. The derivative of sin(x²) is 2x cos(x²).
  • Stopping after one layer: sin³(4x) has three layers, so its derivative has three factors, 3 sin²(4x) · cos(4x) · 4.
  • Using the chain rule on a product: x² sin x is x² times sin x, so it needs the product rule.
  • Leaving u in the answer: after multiplying, replace u with the inside so the derivative is written in terms of x.

Key terms

Chain rule
The rule for differentiating a function inside another function: differentiate the outside, keeping the inside as it is, then multiply by the derivative of the inside.
Composition of functions
Feeding one function’s output into another, written f(g(x)). The inner output has to be an allowed input for the outer function.
Derivative
The instantaneous rate of change of a function: the limit of the average rate of change as the step shrinks to zero, when that limit exists. On a graph it is the slope of the tangent line.
Product rule
To differentiate a product, take the derivative of the first factor times the second, plus the first times the derivative of the second: (uv)′ = u′v + uv′.

Work through an example

Differentiate y = (3x + 1)² with the chain rule, then check by expanding.

Differentiate (3x + 1)² with the chain rule →

Differentiate sin(x²) and sin²x →

Differentiate a square root with the chain rule →

Differentiate e^(−x²) with the chain rule →

Differentiate a function with three layers →

Combine the chain rule and the product rule →

Sources and scope

Authored study material. Tool results depend on the stated inputs and model assumptions.

Make it concrete

Try in the workspace

Open the example inputs, change a value and keep a useful result on your board.

Open Chain Rule Composition Check the derivative in Math Open worked example on a board Chain rule in Math Reference

Your existing work stays on this device. Examples open as editable copies.