The Chain Rule: How It Works, With Worked Examples
Learn the chain rule step by step: what it says, why it works, how to spot the inside function, and worked examples with powers, trig, e^x and ln.
By the PracticeCalculus team Published 5 min read
On this page
- What the chain rule says
- Why it works: rates multiply
- How to find the inside function
- Worked example 1: a power of a polynomial
- Worked example 2: a trig function
- Worked example 3: exponentials and logarithms
- Worked example 4: a square root
- Using the chain rule more than once
- Chain rule with the product rule
- Common chain rule mistakes
- Quick reference
- Practice makes it automatic
The power rule handles x^5 in one line. But what about (3x+1)^5? Expanding it would take a page of algebra. The chain rule gets you there in one step, and it is the rule you will use more than any other in calculus.
This guide explains what the chain rule says, why it works, how to find the "inside" function, and walks through worked examples you can follow line by line.
What the chain rule says
A composite function is one function plugged into another, written f(g(x)). We call g the inside function and f the outside function.
The chain rule says:
Read it as a recipe:
- Differentiate the outside function, but leave the inside exactly as it is.
- Multiply by the derivative of the inside function.
That is the whole rule. Everything else is practice at spotting which part is inside.
In Leibniz notation, if y = f(u) and u = g(x), the same rule reads
which looks like fractions cancelling. They are not really fractions, but it is a great way to remember it.
Why it works: rates multiply
Imagine three gears. Gear u turns 3 times for every turn of gear x. Gear y turns 2 times for every turn of gear u. How many times does y turn for each turn of x? Six: 2 \cdot 3.
Derivatives are rates of change, and rates of change in a chain multiply in exactly the same way. That is all the chain rule is saying: the rate of the whole chain is the product of the rates of each link.
The graph shows why the inside matters. If you differentiated \sin(x^2) as just \cos(x^2), the slope could never be larger than 1. But the curve clearly gets steeper the further you go from 0. The factor 2x from the inside is what captures that.
How to find the inside function
Ask yourself: what would I compute last if I were evaluating this with a calculator? That last operation is the outside function. Whatever it acts on is the inside.
| Function | Outside | Inside |
|---|---|---|
| (3x+1)^5 | u^5 | 3x + 1 |
| \sin(x^2) | \sin u | x^2 |
| e^{4x} | e^u | 4x |
| \sqrt{x^2+9} | \sqrt{u} | x^2 + 9 |
| \ln(\cos x) | \ln u | \cos x |
A quick test: if the inside is just x, you do not need the chain rule (the inside derivative would be 1). The moment the inside is anything more, you do.
Worked example 1: a power of a polynomial
Differentiate y = (3x+1)^5.
Step 1. Name the pieces. Outside: u^5. Inside: u = 3x+1.
Step 2. Differentiate the outside, keep the inside. The derivative of u^5 is 5u^4, so we get 5(3x+1)^4.
Step 3. Multiply by the inside derivative. The derivative of 3x + 1 is 3.
Notice that we never expanded (3x+1)^5. That is the power of the chain rule.
Worked example 2: a trig function
Differentiate y = \sin(x^2).
- Outside: \sin u, with derivative \cos u.
- Inside: u = x^2, with derivative 2x.
A common slip is writing \cos(2x). The inside stays as x^2 inside the cosine. The 2x goes outside, as a factor.
Worked example 3: exponentials and logarithms
Differentiate y = e^{4x}.
The derivative of e^u is e^u itself, so the outside part is e^{4x}. The inside 4x has derivative 4:
Now differentiate y = \ln(x^2 + 1).
The derivative of \ln u is \frac{1}{u}, and the inside x^2+1 has derivative 2x:
Worked example 4: a square root
Differentiate y = \sqrt{x^2 + 9}.
Rewrite the root as a power first: y = (x^2+9)^{1/2}. Then:
Rewriting roots as fractional powers makes the chain rule (and the power rule) much easier to apply.
Using the chain rule more than once
Some functions have several layers, like an onion. Peel them one at a time from the outside in, and multiply every derivative together.
Differentiate y = \sin^3(2x), which means \left(\sin(2x)\right)^3.
- Outermost layer, the cube: 3\sin^2(2x).
- Middle layer, the sine: \cos(2x).
- Innermost layer, 2x: 2.
Tip: say the layers out loud. "Cube of sine of two x." Then differentiate in that same order.
Chain rule with the product rule
Many real problems mix rules. Differentiate y = x^2 \sin(3x).
This is a product, so start with the product rule, (uv)' = u'v + uv', and use the chain rule inside it for \sin(3x):
The chain rule only appeared in one place: the derivative of \sin(3x) is 3\cos(3x).
Common chain rule mistakes
These are the slips our answer checker sees most often, in order:
- Forgetting the inside derivative. Writing \frac{d}{dx}(3x+1)^5 = 5(3x+1)^4. The missing factor of 3 is the single most common chain rule error.
- Changing the inside. Writing \frac{d}{dx}\sin(x^2) = \cos(2x). The inside stays the same inside the outer derivative.
- Applying it when it is not needed. \frac{d}{dx}\sin x is just \cos x. There is no extra factor because the inside is plain x.
- Stopping one layer early. In \sin^3(2x), it is easy to forget the final factor of 2.
A good habit: after you finish, count your layers and check that you have one derivative factor for each.
Quick reference
| Function | Derivative |
|---|---|
| (g(x))^n | n(g(x))^{n-1}\, g'(x) |
| \sin(g(x)) | \cos(g(x))\, g'(x) |
| \cos(g(x)) | -\sin(g(x))\, g'(x) |
| e^{g(x)} | e^{g(x)}\, g'(x) |
| \ln(g(x)) | \frac{g'(x)}{g(x)} |
| \sqrt{g(x)} | \frac{g'(x)}{2\sqrt{g(x)}} |
Practice makes it automatic
The chain rule clicks through repetition. Once you have done twenty or thirty, you will spot the inside function without thinking. Try the interactive lesson below: every question gives you instant feedback, points out exactly which factor you missed, and walks through the solution step by step.
Practice it now
Chain rule: powers
Solve real problems on this topic with instant feedback, hints and a step-by-step walkthrough for every answer. Free, no sign-up needed to start.
Practice this lesson