The chain rule, explained with examples
The chain rule is how you differentiate a function inside another function. It appears in almost every calculus question, so it is worth making it automatic.
On this page
What the chain rule says
A composite function is a function of a function, such as sin(3x), (2x + 1)5 or ex². Each has an outer function applied to an inner function. The chain rule says:
If y = f(g(x)), then dy/dx = f'(g(x)) × g'(x).
In words: differentiate the outer function, leaving the inside alone, then multiply by the derivative of the inside. In Leibniz notation, with u = g(x), this is dy/dx = dy/du × du/dx. The notation makes the rule look like fractions cancelling, which is a useful way to remember it, even though derivatives are not really fractions.
Why it works
Think of rates of change multiplying. If u changes 3 times as fast as x, and y changes 5 times as fast as u, then y changes 15 times as fast as x. The chain rule is that idea made precise: the rate of the whole is the product of the rates of each link in the chain. This is also why it is called the chain rule.
How to spot the inner and outer function
Ask yourself: if I worked out this function on a calculator, what would I do last? The last step is the outer function. For (2x + 1)5, you would work out 2x + 1 first and then raise it to the fifth power, so the outer function is “to the fifth” and the inner is 2x + 1. For sin(3x), you find 3x first and then take sine, so sine is outer and 3x is inner.
Worked examples
Example 1: a power of a bracket
Differentiate y = (2x + 1)5.
- Outer: u5, derivative 5u4. Inner: u = 2x + 1, derivative 2.
- dy/dx = 5(2x + 1)4 × 2 = 10(2x + 1)4.
Example 2: trigonometry
Differentiate y = sin(3x).
- Outer: sin u, derivative cos u. Inner: 3x, derivative 3.
- dy/dx = 3cos(3x).
Example 3: an exponential
Differentiate y = ex².
- Outer: eu, derivative eu. Inner: x², derivative 2x.
- dy/dx = 2x ex².
Example 4: a logarithm
Differentiate y = ln(x² + 4).
- Outer: ln u, derivative 1/u. Inner: x² + 4, derivative 2x.
- dy/dx = 2x/(x² + 4). In general, the derivative of ln(f(x)) is f'(x)/f(x).
Example 5: a square root
Differentiate y = √(1 − x²).
- Write it as (1 − x²)1/2. Outer derivative: ½u−1/2. Inner derivative: −2x.
- dy/dx = ½(1 − x²)−1/2 × (−2x) = −x/√(1 − x²).
Example 6: a power of a trig function
Differentiate y = sin²x.
- sin²x means (sin x)². Outer: u², derivative 2u. Inner: sin x, derivative cos x.
- dy/dx = 2 sin x cos x, which also equals sin 2x.
Example 7: three layers
Differentiate y = cos³(4x).
- Three links: cube, then cosine, then 4x.
- dy/dx = 3cos²(4x) × (−sin(4x)) × 4 = −12cos²(4x) sin(4x). Work from the outside in, one layer at a time.
Example 8: chain rule with the product rule
Differentiate y = x(3x − 2)4.
- Product rule: u = x, v = (3x − 2)4. By the chain rule, v' = 4(3x − 2)³ × 3 = 12(3x − 2)³.
- dy/dx = (3x − 2)4 + 12x(3x − 2)³ = (3x − 2)³(3x − 2 + 12x) = (3x − 2)³(15x − 2).
Example 9: from a table (AP style)
f(2) = 5, f'(2) = −1, g(1) = 2 and g'(1) = 3. Find h'(1) where h(x) = f(g(x)).
- h'(1) = f'(g(1)) × g'(1) = f'(2) × 3.
- = −1 × 3 = −3. A very common AP multiple-choice format.
A quick routine for every chain rule question
- Rewrite roots and fractions as powers, so √u becomes u1/2 and 1/u² becomes u−2.
- Name the inner function u and write down du/dx.
- Differentiate the outer function with respect to u, keeping u inside.
- Multiply the two results and replace u with the original expression.
- Simplify, often by taking out common factors.
Writing u and du/dx at the side of your working takes a few seconds and prevents most errors. Once the pattern is automatic, you can skip the u and do it in one line, which saves valuable time in the exam and leaves more time for checking.
Where the chain rule turns up next
Once you know the chain rule, several other topics become straightforward. Implicit differentiation is the chain rule applied to y as a function of x, which is why the derivative of y² is 2y(dy/dx). Related rates are the chain rule with time as the variable. Integration by substitution is the chain rule in reverse. Derivatives of inverse functions also come from it. If you are unsure about any of these, the chain rule is usually the place to start.
Common mistakes
- Forgetting to multiply by the derivative of the inner function, for example writing the derivative of sin(3x) as cos(3x).
- Changing the inside of the outer derivative, for example writing 5(2)4 instead of 5(2x + 1)4.
- Mixing up sin²x and sin(x²); they need different chains.
- Stopping after two layers when the function has three.
Practice questions
Try each one before opening the answer.
Q1. Differentiate (x³ − 1)6.
Show answer
Q2. Differentiate cos(5x + 2).
Show answer
Q3. Differentiate e−2x.
Show answer
Q4. Differentiate ln(sin x).
Show answer
Q5. Differentiate tan(x²).
Show answer
Q6. If h(x) = g(x)², g(3) = 4 and g'(3) = −2, find h'(3).
Show answer
Frequently asked questions
Is the chain rule on the AP Calculus exam?
Yes, in both AB and BC, in multiple-choice and free-response questions. It is part of Unit 3 on composite, implicit and inverse functions, and it is used throughout the rest of the course.
Is the chain rule in A level Maths?
Yes. It is in the second year of A level Maths, alongside the product and quotient rules.
How do I know when to use the chain rule?
Whenever there is something other than plain x inside a function: a bracket raised to a power, sin of something, e to the power of something, ln of something, or a square root of an expression.
Key takeaways
- Differentiate the outside, keep the inside, multiply by the derivative of the inside.
- dy/dx = dy/du × du/dx.
- Find the outer function by asking what you would do last.
- Work from the outside in for three or more layers.
- The chain rule underpins implicit differentiation, related rates and substitution.