Skip to content
Family Table Math

The Chain Rule

You already know how to differentiate x4x^4, sin⁡x\sin x, exe^x, and ln⁡x\ln x. But what about (3x2−5)4(3x^2 - 5)^4, sin⁡(5x2)\sin(5x^2), or e−3xe^{-3x}? These are composite functions: one function sitting inside another. The chain rule tells you how to differentiate them, and it’s the rule you’ll use more than any other in calculus. All trig on this page is in radians, as in all of AP Calculus.

A composite function f(g(x))f(g(x)) has an outside function ff and an inside function gg. To spot them, ask: “If I were evaluating this on a calculator, what would I do last?” The last step is the outside.

FunctionInside g(x)g(x)Outside f(u)f(u)
(3x2−5)4(3x^2 - 5)^43x2−53x^2 - 5u4u^4
sin⁡(5x2)\sin(5x^2)5x25x^2sin⁡u\sin u
e−3xe^{-3x}−3x-3xeue^u
ln⁡(x2+4)\ln(x^2 + 4)x2+4x^2 + 4ln⁡u\ln u
cos⁡3x=(cos⁡x)3\cos^3 x = (\cos x)^3cos⁡x\cos xu3u^3
ddx[f(g(x))]=f′(g(x))⋅g′(x)\frac{d}{dx}\Big[f\big(g(x)\big)\Big] = f'\big(g(x)\big) \cdot g'(x)

In words: differentiate the outside, leave the inside alone, then multiply by the derivative of the inside.

If y=f(u)y = f(u) and u=g(x)u = g(x), then

dydx=dydu⋅dudx\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}

This form shows why the rule works: if yy changes 33 times as fast as uu, and uu changes 22 times as fast as xx, then yy changes 3×2=63 \times 2 = 6 times as fast as xx. Rates of change multiply along the chain. (The dudu‘s look like they cancel. They aren’t really fractions, but it’s a handy memory aid.)

Each basic rule from derivatives of trig, exponential, and log functions gets a “times u′u'” at the end, where uu is the inside function:

FunctionDerivative
unu^nnun−1⋅u′n u^{n-1} \cdot u'
sin⁡u\sin ucos⁡u⋅u′\cos u \cdot u'
cos⁡u\cos u−sin⁡u⋅u′-\sin u \cdot u'
tan⁡u\tan usec⁡2u⋅u′\sec^2 u \cdot u'
eue^ueu⋅u′e^u \cdot u'
aua^uauln⁡a⋅u′a^u \ln a \cdot u'
ln⁡u\ln uu′u\dfrac{u'}{u}

For more than two layers, keep going: work from the outside in, multiplying by the derivative of each layer. For example, sin⁡3(2x)\sin^3(2x) has three layers (cube, sine, 2x2x):

ddx[sin⁡(2x)]3=3sin⁡2(2x)⋅cos⁡(2x)⋅2\frac{d}{dx}\big[\sin(2x)\big]^3 = 3\sin^2(2x) \cdot \cos(2x) \cdot 2

If h(x)=f(g(x))h(x) = f(g(x)), then h′(a)=f′(g(a))⋅g′(a)h'(a) = f'(g(a)) \cdot g'(a). With a table, work in this order:

  1. Find g(a)g(a) in the table.
  2. Look up f′f' at that value, g(a)g(a), not at aa.
  3. Multiply by g′(a)g'(a).

Real functions often need several rules at once (CED 3.5). Look at the overall structure first:

  • Is the whole thing a product or quotient of two pieces? Start with the product rule or quotient rule, and use the chain rule on any piece that’s composite.
  • Is the whole thing one function of another? Start with the chain rule.
  • Rewrite first when it makes life easier: x2+9=(x2+9)1/2\sqrt{x^2 + 9} = (x^2 + 9)^{1/2}, and 4(x2+1)3=4(x2+1)−3\dfrac{4}{(x^2 + 1)^3} = 4(x^2 + 1)^{-3} needs only the chain rule, not the quotient rule.

On the AP exam, these are mostly no-calculator skills, so practise until they’re automatic.

Differentiate y=(3x2−5)4y = (3x^2 - 5)^4.

Solution. The outside is u4u^4 and the inside is u=3x2−5u = 3x^2 - 5, with u′=6xu' = 6x.

dydx=4(3x2−5)3⋅6x=24x(3x2−5)3\frac{dy}{dx} = 4(3x^2 - 5)^3 \cdot 6x = 24x(3x^2 - 5)^3

Don’t expand (3x2−5)4(3x^2 - 5)^4 first. It works, but it’s slow and easy to get wrong.

Example 2: Trig, exponential, and log compositions

Section titled “Example 2: Trig, exponential, and log compositions”

Differentiate each function.

(a) sin⁡(5x2)\sin(5x^2) (b) e−3xe^{-3x} (c) ln⁡(x2+4)\ln(x^2 + 4) (d) cos⁡3x\cos^3 x

Solution.

(a) Outside sin⁡u\sin u, inside 5x25x^2:

ddxsin⁡(5x2)=cos⁡(5x2)⋅10x=10xcos⁡(5x2)\frac{d}{dx}\sin(5x^2) = \cos(5x^2) \cdot 10x = 10x\cos(5x^2)

(b) Outside eue^u, inside −3x-3x:

ddxe−3x=e−3x⋅(−3)=−3e−3x\frac{d}{dx}e^{-3x} = e^{-3x} \cdot (-3) = -3e^{-3x}

(c) Outside ln⁡u\ln u, inside x2+4x^2 + 4:

ddxln⁡(x2+4)=1x2+4⋅2x=2xx2+4\frac{d}{dx}\ln(x^2 + 4) = \frac{1}{x^2 + 4} \cdot 2x = \frac{2x}{x^2 + 4}

(d) Rewrite as (cos⁡x)3(\cos x)^3. Outside u3u^3, inside cos⁡x\cos x:

ddx(cos⁡x)3=3(cos⁡x)2⋅(−sin⁡x)=−3cos⁡2xsin⁡x\frac{d}{dx}(\cos x)^3 = 3(\cos x)^2 \cdot (-\sin x) = -3\cos^2 x \sin x

The table gives values of ff, gg, and their derivatives.

xxf(x)f(x)f′(x)f'(x)g(x)g(x)g′(x)g'(x)
1144−2-23355
33776611−4-4

(a) Let h(x)=f(g(x))h(x) = f(g(x)). Find h′(1)h'(1).

(b) Let k(x)=(f(x))2k(x) = \big(f(x)\big)^2. Find k′(3)k'(3).

Solution.

(a) h′(1)=f′(g(1))⋅g′(1)h'(1) = f'(g(1)) \cdot g'(1). From the table, g(1)=3g(1) = 3, so we need f′(3)=6f'(3) = 6:

h′(1)=f′(3)⋅g′(1)=6⋅5=30h'(1) = f'(3) \cdot g'(1) = 6 \cdot 5 = 30

(b) The outside is u2u^2 and the inside is f(x)f(x), so k′(x)=2f(x)⋅f′(x)k'(x) = 2f(x) \cdot f'(x):

k′(3)=2f(3)⋅f′(3)=2(7)(6)=84k'(3) = 2f(3) \cdot f'(3) = 2(7)(6) = 84

Example 4: Product rule and chain rule together

Section titled “Example 4: Product rule and chain rule together”

Find the equation of the tangent line to y=x21+4xy = x^2\sqrt{1 + 4x} at x=2x = 2.

Solution. Overall, this is a product of x2x^2 and (1+4x)1/2(1 + 4x)^{1/2}, so start with the product rule. The second factor needs the chain rule:

ddx(1+4x)1/2=12(1+4x)−1/2⋅4=21+4x\frac{d}{dx}(1 + 4x)^{1/2} = \frac{1}{2}(1 + 4x)^{-1/2} \cdot 4 = \frac{2}{\sqrt{1 + 4x}}

So

dydx=2x1+4x+x2⋅21+4x\frac{dy}{dx} = 2x\sqrt{1 + 4x} + x^2 \cdot \frac{2}{\sqrt{1 + 4x}}

At x=2x = 2: 1+8=3\sqrt{1 + 8} = 3, so

y=4(3)=12,dydx=2(2)(3)+4(2)3=12+83=443y = 4(3) = 12, \qquad \frac{dy}{dx} = 2(2)(3) + \frac{4(2)}{3} = 12 + \frac{8}{3} = \frac{44}{3}

The tangent line is

y−12=443(x−2)y - 12 = \frac{44}{3}(x - 2)

Forgetting to multiply by the inside derivative. ddxsin⁡(3x)\dfrac{d}{dx}\sin(3x) is 3cos⁡(3x)3\cos(3x), not cos⁡(3x)\cos(3x). Even when the inside is something simple like 3x3x or −x-x, its derivative still counts.

Changing the inside when differentiating the outside. ddxcos⁡(x2)=−sin⁡(x2)⋅2x\dfrac{d}{dx}\cos(x^2) = -\sin(x^2) \cdot 2x. A common wrong answer is −sin⁡(2x)-\sin(2x), which differentiates the inside inside the cosine. The inside stays exactly as it was; its derivative goes out front.

Using the wrong values from a table. For h(x)=f(g(x))h(x) = f(g(x)), h′(a)=f′(g(a))⋅g′(a)h'(a) = f'(g(a)) \cdot g'(a). Students often write f′(a)⋅g′(a)f'(a) \cdot g'(a) or f′(g′(a))f'(g'(a)). Always find g(a)g(a) first, then look up f′f' there.

Confusing sin²x with sin(x²). sin⁡2x=(sin⁡x)2\sin^2 x = (\sin x)^2 has outside u2u^2, so its derivative is 2sin⁡xcos⁡x2\sin x\cos x. But sin⁡(x2)\sin(x^2) has outside sin⁡u\sin u, so its derivative is 2xcos⁡(x2)2x\cos(x^2).

Dropping the inside derivative with ln. ddxln⁡(x2+1)=2xx2+1\dfrac{d}{dx}\ln(x^2 + 1) = \dfrac{2x}{x^2 + 1}, not 1x2+1\dfrac{1}{x^2 + 1}. Remember the pattern “derivative of the inside over the inside”.

Using degrees. Calculus derivative rules like ddxsin⁡x=cos⁡x\dfrac{d}{dx}\sin x = \cos x only work in radians. Make sure your calculator is in radian mode on the AP exam.

1. (Warm-up) Differentiate y=(2x+7)5y = (2x + 7)^5.

Solution

Outside u5u^5, inside 2x+72x + 7 with derivative 22:

dydx=5(2x+7)4⋅2=10(2x+7)4\frac{dy}{dx} = 5(2x + 7)^4 \cdot 2 = 10(2x + 7)^4

2. (Warm-up) Differentiate each function.

  • (a) e4xe^{4x}
  • (b) x2+9\sqrt{x^2 + 9}
Solution

(a) ddxe4x=e4x⋅4=4e4x\dfrac{d}{dx}e^{4x} = e^{4x} \cdot 4 = 4e^{4x}

(b) Rewrite as (x2+9)1/2(x^2 + 9)^{1/2}:

ddx(x2+9)1/2=12(x2+9)−1/2⋅2x=xx2+9\frac{d}{dx}(x^2 + 9)^{1/2} = \frac{1}{2}(x^2 + 9)^{-1/2} \cdot 2x = \frac{x}{\sqrt{x^2 + 9}}

3. (Core) Differentiate y=ln⁡(cos⁡x)y = \ln(\cos x) and simplify.

Solution

Outside ln⁡u\ln u, inside cos⁡x\cos x:

dydx=−sin⁡xcos⁡x=−tan⁡x\frac{dy}{dx} = \frac{-\sin x}{\cos x} = -\tan x

4. (Core) Let y=u3−2uy = u^3 - 2u and u=x2+1u = x^2 + 1. Use dydx=dydu⋅dudx\dfrac{dy}{dx} = \dfrac{dy}{du} \cdot \dfrac{du}{dx} to find dydx\dfrac{dy}{dx} when x=1x = 1.

Solution

dydu=3u2−2\dfrac{dy}{du} = 3u^2 - 2 and dudx=2x\dfrac{du}{dx} = 2x.

When x=1x = 1, u=12+1=2u = 1^2 + 1 = 2, so

dydx=(3(2)2−2)(2⋅1)=10⋅2=20\frac{dy}{dx} = (3(2)^2 - 2)(2 \cdot 1) = 10 \cdot 2 = 20

5. (Core) Use the table.

xxf(x)f(x)f′(x)f'(x)g(x)g(x)g′(x)g'(x)
00223355−1-1
2200−4-41166
  • (a) If h(x)=g(f(x))h(x) = g(f(x)), find h′(0)h'(0).
  • (b) If k(x)=f(f(x))k(x) = f(f(x)), find k′(2)k'(2).
  • (c) If m(x)=eg(x)m(x) = e^{g(x)}, find m′(2)m'(2).
Solution

(a) h′(0)=g′(f(0))⋅f′(0)=g′(2)⋅3=6⋅3=18h'(0) = g'(f(0)) \cdot f'(0) = g'(2) \cdot 3 = 6 \cdot 3 = 18

(b) k′(2)=f′(f(2))⋅f′(2)=f′(0)⋅(−4)=3(−4)=−12k'(2) = f'(f(2)) \cdot f'(2) = f'(0) \cdot (-4) = 3(-4) = -12

(c) m′(x)=eg(x)⋅g′(x)m'(x) = e^{g(x)} \cdot g'(x), so m′(2)=eg(2)⋅g′(2)=e1⋅6=6em'(2) = e^{g(2)} \cdot g'(2) = e^1 \cdot 6 = 6e

6. (Core) Differentiate y=4(x2+1)3y = \dfrac{4}{(x^2 + 1)^3} without using the quotient rule.

Solution

Rewrite as y=4(x2+1)−3y = 4(x^2 + 1)^{-3}:

dydx=4⋅(−3)(x2+1)−4⋅2x=−24x(x2+1)4\frac{dy}{dx} = 4 \cdot (-3)(x^2 + 1)^{-4} \cdot 2x = -\frac{24x}{(x^2 + 1)^4}

7. (Core) The depth of water at a dock is D(t)=3+1.5sin⁡(πt6)D(t) = 3 + 1.5\sin\left(\dfrac{\pi t}{6}\right) metres, tt hours after midnight. How fast is the depth changing at t=2t = 2? Give an exact answer and a decimal to three places, with units.

SolutionD′(t)=1.5cos⁡(πt6)⋅π6=π4cos⁡(πt6)D'(t) = 1.5\cos\left(\frac{\pi t}{6}\right) \cdot \frac{\pi}{6} = \frac{\pi}{4}\cos\left(\frac{\pi t}{6}\right)D′(2)=π4cos⁡(π3)=π4⋅12=π8≈0.393D'(2) = \frac{\pi}{4}\cos\left(\frac{\pi}{3}\right) = \frac{\pi}{4} \cdot \frac{1}{2} = \frac{\pi}{8} \approx 0.393

The depth is increasing at about 0.3930.393 metres per hour.

8. (Challenge) Let y=sin⁡3(2x)y = \sin^3(2x). Find dydx\dfrac{dy}{dx}, then evaluate it at x=π12x = \dfrac{\pi}{12}.

Solution

Three layers: the cube, the sine, and 2x2x.

dydx=3sin⁡2(2x)⋅cos⁡(2x)⋅2=6sin⁡2(2x)cos⁡(2x)\frac{dy}{dx} = 3\sin^2(2x) \cdot \cos(2x) \cdot 2 = 6\sin^2(2x)\cos(2x)

At x=π12x = \dfrac{\pi}{12}, 2x=π62x = \dfrac{\pi}{6}, with sin⁡π6=12\sin\dfrac{\pi}{6} = \dfrac{1}{2} and cos⁡π6=32\cos\dfrac{\pi}{6} = \dfrac{\sqrt{3}}{2}:

dydx=6⋅14⋅32=334\frac{dy}{dx} = 6 \cdot \frac{1}{4} \cdot \frac{\sqrt{3}}{2} = \frac{3\sqrt{3}}{4}

9. (Challenge) Find all points where the graph of y=xe−x2y = xe^{-x^2} has a horizontal tangent line.

Solution

Product rule, with the chain rule on e−x2e^{-x^2}:

dydx=1⋅e−x2+x⋅e−x2(−2x)=e−x2(1−2x2)\frac{dy}{dx} = 1 \cdot e^{-x^2} + x \cdot e^{-x^2}(-2x) = e^{-x^2}(1 - 2x^2)

Since e−x2>0e^{-x^2} \gt 0 always, dydx=0\dfrac{dy}{dx} = 0 only when 1−2x2=01 - 2x^2 = 0, so x=±12x = \pm\dfrac{1}{\sqrt{2}}.

The yy-values are y=±12e−1/2y = \pm\dfrac{1}{\sqrt{2}}e^{-1/2}, so the points are

(12, 12e−1/2)and(−12, −12e−1/2)\left(\frac{1}{\sqrt{2}},\ \frac{1}{\sqrt{2}}e^{-1/2}\right) \quad\text{and}\quad \left(-\frac{1}{\sqrt{2}},\ -\frac{1}{\sqrt{2}}e^{-1/2}\right)

That’s about (0.707,0.429)(0.707, 0.429) and (−0.707,−0.429)(-0.707, -0.429).