AP · Calculus AB · The Chain Rule and Implicit Differentiation
The Chain Rule
17 min readUpdated November 30, 2026FreeAP Calculus AB, Chain Rule, Implicit and Inverse Derivatives
The chain rule differentiates a composite function, one function applied to the output of another: dxd[f(g(x))]=f′(g(x))⋅g′(x). In words, you differentiate the outside function with the inside left alone, then multiply by the derivative of the inside. It works for chains of any length and inside the product and quotient rules.
Quick check
1What is the derivative of x2cosx?Show answerHide answer
2xcosx−x2sinx, by the product rule. See the note on the product rule and the quotient rule if that step is shaky.
2If f(x)=x3 and g(x)=2x+1, what is f(g(x))?Show answerHide answer
(2x+1)3. The output of g becomes the input of f.
3Is the derivative of (2x+1)3 equal to 3(2x+1)2?Show answerHide answer
No. That is only the derivative of the outside. You must also multiply by 2, the derivative of 2x+1, which gives 6(2x+1)2.
Identify the inside and outside functions of a composite.
Calculate derivatives of composites using f′(g(x))⋅g′(x) or dudy⋅dxdu.
Apply the chain rule more than once when three functions are chained together.
Combine the chain rule with the product and quotient rules.
Evaluate the derivative of a composite at a point from a table of values.
Key terms
Composite function
A function of the form f(g(x)), where the output of g is fed into f.
In plain English
A function inside another function.
Don't write
f(g(x))=f(x)⋅g(x); a composite is not a product.
Inside and outside functions
In f(g(x)),g is the inside function and f is the outside function.
In plain English
The outside is the last thing you would do if you worked out the value with a calculator.
Don't write
"the inside of sin2x is x2"; sin2x means (sinx)2, so the inside is sinx.
Chain rule
For differentiable f and g, the derivative of f(g(x)) is f′(g(x))⋅g′(x).
In plain English
Derivative of the outside, with the inside unchanged, times the derivative of the inside.
Don't write
f′(g′(x)); the inside stays as g(x) in the first factor.
How do you spot the inside and outside functions?
Ask what you would calculate last if you had a value of x. That last step is the outside function; whatever it acts on is the inside.
Expression
Last step (outside)
Inside
sin(x2)
sinu
u=x2
sin2x=(sinx)2
u2
u=sinx
e3x
eu
u=3x
x2+1
u
u=x2+1
ln(cosx)
lnu
u=cosx
The letter u is a label for the inside. Naming it lets you see a familiar outside function, such as u2 or eu, whose derivative you already know.
If the "inside" is just x, as in sinx, there is no chain and no extra factor.
Check yourself
What are the inside and outside functions of ln(x2+4)?
Show answerHide answer
The outside is lnu and the inside is u=x2+4. You would add 4 to x2 first, and take the natural log last.
What does the chain rule say?
Learn this: in function notation,
dxd[f(g(x))]=f′(g(x))⋅g′(x)
and in Leibniz notation, with y=f(u) and u=g(x),
dxdy=dudy⋅dxdu
The two say the same thing. Rates multiply: if u changes 3 times as fast as x, and y changes 2 times as fast as u, then y changes 6 times as fast as x.
Take y=(x2+5)4. The outside is u4, with derivative 4u3; the inside is u=x2+5, with derivative 2x. So
dxdy=4(x2+5)3⋅2x=8x(x2+5)3
Three patterns come up so often that they are worth knowing on sight:
dxd[eg(x)]=eg(x)⋅g′(x)
dxd[lng(x)]=g(x)g′(x)
dxd[sin(kx)]=kcos(kx), and dxd[cos(kx)]=−ksin(kx)
Key idea
Differentiate the outside with the inside left untouched, then multiply by the derivative of the inside.
Check yourself
Differentiate y=e−3x.
Show answerHide answer
−3e−3x. The outside eu stays as e−3x, and the inside −3x has derivative −3.
What if three functions are chained together?
Apply the rule once for each layer, working from the outside in, and multiply all the factors.
Take y=sin3(4x), which means (sin(4x))3. There are three layers: cubing, then sine, then 4x.
Each factor is the derivative of one layer, with everything inside that layer left as it was. A useful self-check: count the layers, then count the factors in your answer. They should match.
Examiner's eye
Points are lost when the innermost factor, such as the 4 here, is missing. Count the layers and check that you have one factor for each.
Check yourself
Differentiate y=cos2(3x).
Show answerHide answer
−6sin(3x)cos(3x). The factors are 2cos(3x) for the square, −sin(3x) for the cosine and 3 for the 3x.
How does the chain rule fit inside the product and quotient rules?
Decide the overall structure first. If the expression is a product or a quotient overall, use that rule, and use the chain rule whenever one of the pieces is itself a composite.
Take y=x2e5x. Overall it is a product, with u=x2 and v=e5x. The piece v needs the chain rule: v′=5e5x. Then
dxdy=2x⋅e5x+x2⋅5e5x=xe5x(2+5x)
The same idea works for a quotient. For y=xsin(2x), the top has derivative 2cos(2x) by the chain rule, so dxdy=x22xcos(2x)−sin(2x).
Check yourself
Differentiate y=xsin(2x).
Show answerHide answer
sin(2x)+2xcos(2x). It is a product, and the derivative of sin(2x) is 2cos(2x) by the chain rule.
How do you use the chain rule with a table?
If h(x)=f(g(x)), then h′(a)=f′(g(a))⋅g′(a). Read it in two moves:
Find g(a) in the table. This is a new input.
Look up f′ at that new input, then multiply by g′(a).
Suppose g(3)=1,g′(3)=4 and f′(1)=−2. Then h′(3)=f′(g(3))⋅g′(3)=f′(1)⋅4=−8. Notice that f′(3) is never used. The outside derivative is evaluated at the output of the inside, not at a.
Check yourself
With the same values, why is f′(3)⋅g′(3) the wrong calculation for h′(3)?
Show answerHide answer
Because f never receives the input 3. It receives g(3)=1, so its derivative must be taken at 1.
Worked example 1: A square root of a quadratic
Question: Find dxdy for y=3x2+1.
What tells you the method
The square root acts on 3x2+1, not on x alone, so this is a composite.
1
Step 1: Rewrite as a power.
y=(3x2+1)1/2, with outside u1/2 and inside u=3x2+1.
Why
The power rule then handles the outside.
2
Step 2: Differentiate the outside.
dudy=21u−1/2=21(3x2+1)−1/2.
Why
The inside stays exactly as it is in this factor.
3
Step 3: Multiply by the derivative of the inside.
dxdu=6x, so dxdy=21(3x2+1)−1/2⋅6x=3x2+13x.
Why
dxdy=dudy⋅dxdu.
Check it
The inside 3x2+1 is smallest at x=0, so y has its lowest point there and the slope should be 0. The formula gives 10=0.
Answer
dxdy=3x2+13x
Worked example 2: Three layers
Question: Let y=esin(2x). Find dxdy, and its value at x=0.
What tells you the method
There are three layers: the exponential, the sine and 2x.
1
Step 1: Outside layer.
The derivative of eu is eu, giving esin(2x).
Why
The outside derivative keeps everything inside it unchanged.
2
Step 2: Middle layer.
The derivative of sin(2x) with respect to its own inside is cos(2x).
Why
The next layer in is the sine.
3
Step 3: Innermost layer.
The derivative of 2x is 2. Multiplying the three factors gives dxdy=2cos(2x)esin(2x).
Why
Three layers give three factors.
4
Step 4: Evaluate at x=0.
2cos0⋅esin0=2⋅1⋅1=2.
Why
cos0=1 and e0=1.
Check it
Near x=0,sin(2x)≈2x, so y≈e2x, whose slope at 0 is 2. That matches.
Answer
dxdy=2cos(2x)esin(2x), and its value at x=0 is 2.
Worked example 3: Composites from a table
Question: The functions f and g are differentiable, with values in the table.
x
f(x)
f′(x)
g(x)
g′(x)
1
3
−2
2
5
2
0
4
1
−3
(a) Let h(x)=f(g(x)). Find h′(1). (b) Let k(x)=(g(x))3. Find k′(2). (c) Let m(x)=xf(2x). Find m′(1).
What tells you the method
Each function is a composite, and m is also a product, so the chain rule sits inside the product rule there.
1
Step 1: Chain rule for h.
h′(1)=f′(g(1))⋅g′(1)=f′(2)⋅5=4⋅5=20.
Why
g(1)=2, so the outside derivative is read at x=2, not at x=1.
2
Step 2: Chain rule for k.
k′(x)=3(g(x))2g′(x), so k′(2)=3(1)2(−3)=−9.
Why
The outside is u3 and the inside is g(x).
3
Step 3: Product rule with a chain for m.
m′(x)=1⋅f(2x)+x⋅f′(2x)⋅2, so m′(1)=f(2)+1⋅f′(2)⋅2=0+8=8.
Why
The derivative of f(2x) is f′(2x)⋅2 by the chain rule.
Check it
In each part, the input to f or f′ is the output of the inside function: g(1)=2 in (a) and 2x=2 in (c). Neither part uses the row for f at x=1.
Answer
(a) h′(1)=20 (b) k′(2)=−9 (c) m′(1)=8
Your turn
Question: Let y=(x2−3x)5. Find dxdy and its value at x=1.
1
Step 1:
The outside is u5, with derivative 5u4; the inside is u=x2−3x.
2
Step 2: Your go: multiply by the derivative of the inside, then substitute x=1.
Show the full solutionHide the solution
The inside has derivative 2x−3, so dxdy=5(x2−3x)4(2x−3). At x=1:5(1−3)4(2−3)=5⋅16⋅(−1)=−80.
Answer:dxdy=5(x2−3x)4(2x−3), and its value at x=1 is −80.
Traps
Trap
Writing the derivative of sin(x2) as cos(x2).
It seems right because the derivative of sin is cos. But that is only the outside layer: the inside x2 changes too, so you multiply by its derivative. The result is 2xcos(x2).
Check yourself
Which is the derivative of ex3:ex3 or 3x2ex3?
Show answerHide answer
3x2ex3. The first one leaves out the derivative of the inside, x3.
Trap
Writing the derivative of sin(x2) as cos(2x).
It seems right because both functions got differentiated. But the inside stays unchanged inside the outside derivative; its derivative goes outside as a separate factor: cos(x2)⋅2x.
Check yourself
Which is the derivative of (x3+1)2:2(3x2) or 2(x3+1)⋅3x2?
Show answerHide answer
2(x3+1)⋅3x2. The first one replaces the inside by its derivative instead of multiplying by it.
Trap
Using f′(a) for the derivative of f(g(x)) at x=a.
It seems right because the question asks about x=a. But f receives the input g(a), so its derivative must be read at g(a):h′(a)=f′(g(a))g′(a).
Check yourself
If g(0)=4,g′(0)=2,f′(0)=7 and f′(4)=−1, what is the derivative of f(g(x)) at x=0?
Show answerHide answer
−2. It is f′(g(0))⋅g′(0)=f′(4)⋅2=−2; the value f′(0)=7 is not needed.
What's examined
The chain rule is part of Unit 3 of the AP® Calculus AB exam, and later topics rely on it: related rates, implicit differentiation, motion and integration by substitution all use it. It can appear in multiple-choice questions and in free-response parts, including composites built from a table of values or a graph. Expect "Find", "Evaluate" and "Write an equation for the line tangent to…". There is no formula sheet, so learn the rule in both notations. In free response, write the chain-rule expression with its values substituted, such as f′(g(1))⋅g′(1)=f′(2)⋅5, before the final number.
Practice questions
Recall Which of the following is dxd[cos(5x)]?
A) −sin(5x)
B) −5sin(5x)
C) 5sin(5x)
D) −sin5
Show answer
Answer: B, −5sin(5x).
Marking points:
Outside derivative −sin(5x), times the inside derivative 5.
A leaves out the inside derivative, C loses the minus sign from the derivative of cos, and D replaces the inside 5x by its derivative.
Recall Differentiate y=ex2−4x.
Show answer
Answer:dxdy=(2x−4)ex2−4x
Marking points:
The outside is eu, whose derivative leaves ex2−4x unchanged.
Multiply by the derivative of the inside, 2x−4.
Apply If y=(4−x3)6, which of the following is dxdy?
A leaves out the inside derivative, B puts the inside derivative in place of the inside, and C loses the minus sign of −3x2.
Apply Let f(x)=x3sin(2x). Find f′(x), and find the exact value of f′(4π).
Show answer
Answer:f′(x)=3x2sin(2x)+2x3cos(2x), and f′(4π)=163π2, which is about 1.851.
Marking points:
Product rule with u=x3 and v=sin(2x); the chain rule gives v′=2cos(2x).
At x=4π:sin2π=1 and cos2π=0, so f′(4π)=3(4π)2=163π2.
Apply The functions f and g are differentiable, with values in the table. Let h(x)=g(f(x)). What is the value of h′(2)?
x
f(x)
f′(x)
g(x)
g′(x)
2
5
3
−1
4
5
7
1
0
2
A) 0
B) 2
C) 6
D) 12
Show answer
Answer: C, 6.
Marking points:
h′(2)=g′(f(2))⋅f′(2)=g′(5)⋅3=2⋅3=6.
A uses g(5) instead of g′(5), B leaves out the factor f′(2), and D reads g′ at 2 instead of at f(2)=5.
Exam-style What is the slope of the line tangent to the graph of y=ln(cosx) at x=3π?
A) −3
B) −323
C) 3
D) 2
Show answer
Answer: A, −3.
Marking points:
dxdy=cosx−sinx=−tanx, and −tan3π=−3.
B divides 1 by the inside derivative −sinx instead of by cosx, C loses the minus sign, and D leaves out the inside derivative, giving cosx1.
Exam-style Let f(x)=cos2(πx). (a) Find f′(x). (b) Find the exact value of f′(41). (c) Write an equation for the line tangent to the graph of f at x=41.
Show answer
Answer: (a) f′(x)=−2πsin(πx)cos(πx) (b) f′(41)=−π (c) y−21=−π(x−41), which is y=−πx+4π+21
Marking points:
Three layers: 2cos(πx) for the square, −sin(πx) for the cosine and π for πx.
At x=41:sin4π=cos4π=22, so f′(41)=−2π⋅21=−π.
f(41)=(22)2=21, so the tangent passes through (41,21) with slope −π.
Key points
Recall, then reveal
Say the main points from memory first, then check them.
Show key pointsHide key points
The outside function is the last operation; the inside is what it acts on.
dxd[f(g(x))]=f′(g(x))g′(x), which is dudy⋅dxdu in Leibniz notation.
One factor per layer: a chain of three functions gives three factors.
Choose the overall rule first (product, quotient or chain), then use the chain rule on any composite piece.
From a table, read g(a) first, then f′ at that value: h′(a)=f′(g(a))g′(a).