The chain rule is how you differentiate a composite function, a function with another function inside it, like (3x + 1)⁵ or sin(x²). It is the most used rule in calculus after the power rule. If the basic rules are new to you, start with derivatives for beginners.
The rule
If y = f(g(x)), then
y′ = f′(g(x)) · g′(x)
In words: take the derivative of the outside function, leave the inside alone, then multiply by the derivative of the inside.
With Leibniz notation, if y depends on u and u depends on x:
dy/dx = dy/du · du/dx
Find the inside and the outside
The inside is whatever is sitting where a plain x would normally go.
| Function | Outside | Inside |
|---|---|---|
| (3x + 1)⁵ | u⁵ | 3x + 1 |
| √(x² + 4) | √u | x² + 4 |
| sin(x²) | sin u | x² |
| e5x | eᵘ | 5x |
| ln(x³ + 1) | ln u | x³ + 1 |
| cos³x | u³ | cos x |
Example Differentiate y = (3x + 1)⁵
- Outside: u⁵, derivative 5u⁴.
- Inside: 3x + 1, derivative 3.
- y′ = 5(3x + 1)⁴ · 3 = 15(3x + 1)⁴.
Forgetting the inside derivative
d/dx (3x + 1)⁵ is not 5(3x + 1)⁴. You can check with a simple case: (2x)² = 4x², whose derivative is 8x. The chain rule gives 2(2x) · 2 = 8x. Leaving off the · 2 gives 4x.
Roots
Rewrite a root as a power, then use the chain rule.
Example Differentiate y = √(x² + 4)
- y = (x² + 4)1/2.
- y′ = ½(x² + 4)−1/2 · 2x.
- y′ = x/√(x² + 4).
Trig, exponential and log functions
The same pattern applies to every rule you know:
| Rule | With the chain rule |
|---|---|
| (sin x)′ = cos x | (sin u)′ = cos u · u′ |
| (cos x)′ = −sin x | (cos u)′ = −sin u · u′ |
| (eˣ)′ = eˣ | (eᵘ)′ = eᵘ · u′ |
| (ln x)′ = 1/x | (ln u)′ = u′/u |
Example Differentiate y = sin(x²)
y′ = cos(x²) · 2x = 2x cos(x²).
Example Differentiate y = e−4x
y′ = e−4x · (−4) = −4e−4x.
Example Differentiate y = ln(x³ + 1)
y′ = 3x²/(x³ + 1).
Example Differentiate y = cos³x
- This means (cos x)³. Outside: u³. Inside: cos x.
- y′ = 3cos²x · (−sin x) = −3 sin x cos²x.
More than two layers
Peel the layers from the outside in, multiplying a derivative for each one.
Example Differentiate y = sin²(3x)
- Three layers: something squared, sine of something, and 3x.
- Squared: 2 sin(3x).
- Sine: cos(3x).
- 3x: 3.
- y′ = 2 sin(3x) · cos(3x) · 3 = 6 sin(3x) cos(3x).
With the product rule
When a product has a composite piece, use the product rule, and the chain rule on that piece.
Example Differentiate y = x²(2x − 1)³
- Product rule: (first)′ · second + first · (second)′.
- (x²)′ = 2x. ((2x − 1)³)′ = 3(2x − 1)² · 2 = 6(2x − 1)².
- y′ = 2x(2x − 1)³ + 6x²(2x − 1)².
- Factor out 2x(2x − 1)²: y′ = 2x(2x − 1)²(2x − 1 + 3x) = 2x(2x − 1)²(5x − 1).
Why it works
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 rates multiply. That’s all dy/dx = dy/du · du/dx says.
Practice problems
Differentiate (4x − 7)³.
Show answer
12(4x − 7)².
Differentiate √(1 − x²).
Show answer
−x/√(1 − x²).
Differentiate cos(5x + 2).
Show answer
−5 sin(5x + 2).
Differentiate ex².
Show answer
2x ex².
Differentiate ln(sin x).
Show answer
cos x/sin x = cot x.
Differentiate x e3x.
Show answer
e3x + 3x e3x = e3x(1 + 3x).