The chain rule differentiates a function inside another function, such as sin(x2) or (3x+1)50. Differentiate the outside function while leaving the inside untouched, then multiply by the derivative of the inside. In symbols, the derivative of f(g(x)) is f′(g(x))⋅g′(x).
A concrete case
Follow one small change
Take y=(3x+1)2. Working out y for a given x happens in two stages. First you find 3x+1, then you square the result. Call the first stage the inside and the second the outside.
Start at x=1. The inside is 3(1)+1=4, and y is 42=16. Now nudge x up by 0.01, to 1.01. The inside becomes 4.03. It moved 0.03, three times as far as x moved. Then y becomes 4.032=16.2409. It moved 0.2409, about eight times as far as the inside moved.
Put the two stages together. y moved about 3×8=24 times as far as x did, and 0.2409÷0.01=24.09 confirms it. The exact rate of change of y at x=1is 24. Each stage multiplied the change by its own rate, and the two rates multiplied. That is the whole idea of the chain rule.
ΔxΔy=0.010.2409=24.09
Following a nudge of 0.01 through y=(3x+1)2 at x=1
Quantity
At x=1
At x=1.01
Change
Compared with the stage before
x
1
1.01
0.01
the nudge
u=3x+1
4
4.03
0.03
3 times the change in x
y=u2
16
16.2409
0.2409
about 8 times the change in u
The rule
Functions built in two stages
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, which is to apply one function to the output of another. This is called composition, and the result is a composite function, written f(g(x)).
sin(x2) is not sinx times x2. The x2 sits inside the sine, and none of the other rules can reach it. (3x+1)50 could be expanded into 51 terms, but the chain rule differentiates it in one line.
To tell the inside from the outside, work 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(x2), you square 2 to get 4 and then take the sine, so the inside is x2 and the outside is the sine. For (3x+1)5, you 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.
sin(x2)(3x+1)50e−x2√x2+1
sin(x2)(3x+1)50e−x2√x2+1
The inside and the outside of common composite functions
Function
Inside, u
Outside, in terms of u
(3x+1)5
3x+1
u5
sin(x2)
x2
sinu
sin2x, which means (sinx)2
sinx
u2
e4x
4x
eu
√x2+1
x2+1
√u
ln(cosx)
cosx
lnu
1/(2x−5)3
2x−5
1/u3, which is u−3
The chain 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 Leibniz notation this is dy/dx=(dy/du)(du/dx).
In function notation the rule says three things. Take the derivative of the outside. Evaluate it at the inside. Multiply by the derivative of the inside. “Evaluate it at the inside” means you find the outside’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).
dxdf(g(x))=f′(g(x))g′(x)
dxdf(g(x))=f′(g(x))g′(x)
Why it works
Why the rates multiply
A derivative is a rate. It says how many times as fast the output changes as the input. In the nudge above, the inside changed 3 times as fast as x, because du/dx=3. The outside changed about 8 times as fast as the inside, because dy/du=2u, which is 8 when u=4. A change in x passes through both stages, and each stage scales it by its own rate. The result is 3×8=24 times the change in x.
Gears make the same point. 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. Nobody adds gear ratios. They multiply.
The nudge gave 24.09 rather than 24 because 0.01 is a small change but not an infinitely small one. A nudge of 0.001 gives 24.009, and as the nudge shrinks the ratio closes in on 24 exactly.
dxdy=dudy⋅dxdu=8⋅3=24
The method
The method in five steps
Until the chain rule feels automatic, write every stage down. The table works through y=sin(x2).
The finished derivative contains only x. If a u is still there, the last step isn’t finished.
dxdy=cos(x2)⋅2x=2xcos(x2)
The five steps of the chain rule on y=sin(x2)
Step
What to do
For y=sin(x2)
1
Name the inside
u=x2
2
Rewrite y using u
y=sinu
3
Differentiate the outside with respect to u
dy/du=cosu
4
Differentiate the inside with respect to x
du/dx=2x
5
Multiply, then put the inside back in place of u
dy/dx=cos(x2)⋅2x=2xcos(x2)
The shortcut without u
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 (x2+5)7, the outside is the 7th power, so write 7(x2+5)6 with the inside copied unchanged. The derivative of the inside is 2x. Multiply to get 14x(x2+5)6.
The table lists the patterns you will use most. Each one is the chain rule with a familiar outside function.
dxd(x2+5)7=7(x2+5)6⋅2x=14x(x2+5)6
dxd(x2+5)7=7(x2+5)6⋅2x=14x(x2+5)6
Chain rule patterns
Function
Derivative
[g(x)]n
n[g(x)]n−1⋅g′(x)
√g(x)
g′(x)/(2√g(x))
eg(x)
eg(x)⋅g′(x)
lng(x)
g′(x)/g(x)
sing(x)
cosg(x)⋅g′(x)
cosg(x)
−sing(x)⋅g′(x)
tang(x)
sec2g(x)⋅g′(x)
An inside of kx, or just x
When the inside is a number times x, its derivative is that number, and the chain rule multiplies by it. The derivative of sin(5x) is 5cos(5x), and the derivative of e3x is 3e3x.
The chain rule is at work even when the inside is plain x. The derivative of sinx is cosx times the derivative of x, which is 1, and a factor of 1 is invisible. That is why the basic rules work without it, and why an extra factor appears as soon as the inside is anything other than x.
dxdsin(5x)=5cos(5x)dxde3x=3e3x
dxdsin(5x)=5cos(5x)dxde3x=3e3x
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=sin3(4x), which means (sin4x)3, the outermost layer is the cube, the middle layer is the sine and the innermost layer is 4x. The cube gives 3sin2(4x), the sine gives cos(4x), and 4xgives 4. Multiply all three to get 12sin2(4x)cos(4x).
Count the layers before you start. The number of factors you multiply should match.
When a problem needs several rules, find the structure at the top level first by asking which operation is done last. In x2e3x, you work out x2 and e3x separately and then multiply. The function is a product, and the product rule comes first. The chain rule appears inside it, when you differentiate the factor e3x.
If the last operation is a function applied to an expression, start with the chain rule instead. In sin(xex), the sine is applied last. The outside is the sine, and its inside, xex, needs the product rule.
dxd(x2e3x)=2xe3x+x2⋅3e3x=xe3x(2+3x)
dxd(x2e3x)=2xe3x+x2⋅3e3x=xe3x(2+3x)
Where it breaks
Where it breaks
The chain rule needs both stages to have a derivative where they are used. The inside must be differentiable at x, and the outside must be differentiable at the value the inside produces. If either fails, the rule gives no answer there.
Take f(x)=√x2. The rule gives f′(x)=2x/(2√x2)=x/√x2, which is 1 for x>0and −1 for x<0. At x=0 the inside is 0, and the square root has no derivative at 0, because its graph is vertical there. The formula breaks down at x=0, and so does the derivative. √x2 is ∣x∣, whose graph has a corner at the origin.
The patterns for √g(x) and lng(x) need g(x)>0 for the same reason. The derivative of ln(x2−4) is 2x/(x2−4), but only where x2−4>0, which means x<−2 or x>2.
The rule also has a shape it fits. It is for a function applied to a function. A product such as x2sinx is not a composition. You work out x2 and sinx separately and multiply, so it needs the product rule. sin2x and sin(x2) are both compositions, built from the same two pieces in opposite orders, and their derivatives differ.
dxd√x2=√x2x={1,−1,x>0x<0
dxd√x2=√x2x={1,−1,x>0x<0
Check your answer
Check your answer
A chain rule derivative most often goes wrong by losing a layer, so test for that first.
Count the factors. A function with two layers needs two factors, and one with three layers needs three.
Try a number. Pick 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)2 expands to 9x2+6x+1, and the power rule gives 18x+6, the same as the chain rule.
To have Chalk check the work, write it in a Math box. Put the function on the first row as f(x)=… and each step of your derivative on its own row below it, f′(x)=…. The Checker marks each row ✓ or ✗ against the row above. Name the function with the variable its formula uses, so a formula in r goes in as f(r) and f′(r). For y=… write the derivative as dy/dx=….
A “?” means Chalk could not follow that row. It is not a ✗, and the work may still be right. Explore on a Math box row, then Differentiate, shows the outside-in steps for a function you type.
Why the rule is true, and where it leads
Leibniz notation makes the chain rule look like cancelling du. That is a good memory aid but not a proof, since 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. Letting Δx shrink to 0 turns the three ratios into the three derivatives. A complete proof must also handle 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.
The chain rule is behind much of what comes next. Implicit differentiation uses it to differentiate y2 as 2y⋅dy/dx. Related rates uses it to link quantities that change together in time. Read backwards, it becomes u-substitution, the first method for undoing a derivative.
ΔxΔy=ΔuΔy⋅ΔxΔu(Δu=0)
Common mistakes
Forgetting the derivative of the inside is the most common slip. The derivative of (3x+1)2 is 2(3x+1)⋅3=18x+6, not 2(3x+1), because the inside changes 3 times as fast as x.
Changing the inside while differentiating the outside. The derivative of sin(x2) is cos(x2)⋅2x. It is not cos(2x) and not cosx⋅2x, because the outside’s derivative is taken at the inside, which stays exactly as it was.
Reading sin2x as sin(x2).sin2x means (sinx)2, whose outside is the square, so its derivative is 2sinxcosx. The derivative of sin(x2) is 2xcos(x2).
Stopping after one layer. sin3(4x) has three layers, so its derivative needs three factors, 3sin2(4x)⋅cos(4x)⋅4. Leaving out the 4 drops the innermost layer’s rate.
Using the chain rule on a product. x2sinx is x2 times sinx, not one function inside another. It needs the product rule, which gives 2xsinx+x2cosx.
Leaving u in the answer. After multiplying, replace u with the inside, so that the derivative is written in terms of x alone.
Key terms
Chain rule
The rule for differentiating a function inside another function: [f(g(x))]′=f′(g(x))⋅g′(x). 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)) or (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)2 with the chain rule, then check by expanding.