Kim’s Math NotesCourse index

The Chain Rule

Why does the chain rule multiply by the derivative of the inside function?

Differentiate a composite function with the chain rule, one layer at a time, and use it for slopes and tangent lines.

Times the inside's derivative

Common mistake ddxx2+5=12x2+5.

Correction Times the inside's derivative 2x: 2x2x2+5=xx2+5.

Same wave, twice as fast

Let's test it. Put sine x and sine two x side by side. Sine two x runs the exact same wave, just on fast-forward: twice as fast. Watch them both leave zero. At zero, sine x climbs out with slope one. Sine two x shoots out twice as steep, with slope two.

Why? The inside, two x, moves twice as fast as x.

Watch this part of the concept lesson

Read the rest of this scene

So every slope along the wave gets multiplied by two. So cosine two x isn't the whole story. Our new guess: the derivative of sine two x is two cosine two x. Let's see why.

Inside and outside

Look at three x plus one, squared. That's two jobs, one right after the other. First job, the inside: take x, triple it, add one. Call that u. u equals three x plus one.

Second job, the outside: square what you got.

Watch this part of the concept lesson

Read the rest of this scene

y equals u squared. In general, y equals f of g of x. g works first, on the inside. f works last, on the outside. Can't tell which part is the inside?

Pretend you're putting a number, like five, into a calculator. Whatever you'd compute first is the inside. Try it on sine squared x. That's sine x, squared: you take the sine first, so sine x is the inside. But sine of x squared: you square first, so x squared is the inside.

And if the inside is just x? Its derivative is one. Times one changes nothing, so you never even noticed it. Back to three x plus one, squared. We can also go the long way.

Expand: nine x squared, plus six x, plus one. Take the derivative, term by term: eighteen x, plus six. Now factor it a sneaky way: two, times three x plus one, times three. Look at the pieces. Two times three x plus one: that's the outside's derivative, with the inside left alone.

And the extra three tagging along? The inside's slope. Maybe that's a fluke, you might say. So try a curved inside: x squared plus one, squared. Expand: x to the fourth, plus two x squared, plus one.

Take the derivative: four x cubed, plus four x. Factor it the same way: two, times x squared plus one, times two x. Look at the tag-along this time. It isn't a number anymore... It's two x: the inside's derivative.

Bet you can beat the algebra now. Call the shot on the cube before you expand it: three, times x squared plus one, squared, times two x. Check it once the long way. Expand: x to the sixth, plus three x to the fourth, plus three x squared, plus one. Its derivative: six x to the fifth, plus twelve x cubed, plus six x.

And the guess multiplies out to six x to the fifth, plus twelve x cubed, plus six x. An exact match.

Why multiply? From the definition

We've seen that it works. But why do the slopes multiply, instead of add? Let's prove it, straight from the definition. By definition, the derivative of f of g of x is the limit, as h goes to zero, of f of g of x plus h, minus f of g of x, all over h. That's crowded. So give the two insides names.

The triangle is g of x plus h. The square is g of x. So it's the limit of f of triangle, minus f of square, over h. Now multiply and divide by triangle minus square: g of x plus h, minus g of x. As long as the inside really moves, that's not zero, so we're allowed.

That splits into a product of fractions: f of triangle minus f of square, over triangle minus square... times g of x plus h, minus g of x, over h.

Watch this part of the concept lesson

Read the rest of this scene

As h goes to zero, where does the triangle go? The triangle slides right into the square, because g is differentiable, so it's continuous. No jumps. The first fraction: the change in f over the change in its input, with the triangle heading to the square. It has the same form as the derivative at a point: f of t minus f of a, over t minus a, as t goes to a. Here the triangle plays t, and the square plays a.

Since f is differentiable at the square, that's f prime of the square: f prime of g of x. And the second fraction is just the definition of g prime of x. So the derivative of f of g of x is f prime of g of x, times g prime of x.

Name the inside: the chain rule

Letters make this easier to carry around. Call the square u. u is g of x, and y is f of u. Then f prime of g of x is dy du: how fast y changes with u. And g prime of x is du dx: how fast u changes with x.

So dy dx is dy du, times du dx.

Watch this part of the concept lesson

Read the rest of this scene

The du's look like they cancel, but dy du and du dx aren't plain fractions: the rates multiply. On our example: u is three x plus one, and y is u squared. dy du is two u, du dx is three. Two u times three is six u. Put u back: six times three x plus one, eighteen x plus six, the same as the long way.

And officially, this has a name: the chain rule. For g differentiable at x and f differentiable at g of x, the derivative of f of g of x is f prime of g of x, times g prime of x. Say it like this: the outside's derivative, with the inside kept just as it is, times the inside's derivative. Outside first, then inside. So, our opening bet.

The outside is sine, so cosine two x, with the two x kept inside, times the inside's derivative, two... Two cosine two x, just what the graph showed at zero.

Box shapes and layers

Some shapes show up all the time. Put the inside in a box. A power of the box gives n times the box to the n minus one... times the box's derivative. e to the box gives e to the box, unchanged... times the box's derivative. The natural log of the box, with the box positive, gives one over the box, times the box's derivative... the box's derivative over the box.

Sine of the box gives cosine of the box, times the box's derivative.

Watch this part of the concept lesson

Read the rest of this scene

Cosine and tangent go the same way: negative sine of the box, and secant squared of the box wherever tangent of the box is defined, each times the box's derivative. Watch that minus sign. And a square root, with the box positive: the power rule again, the box's derivative, over two root the box. These aren't new rules to cram. It's one move in different outfits: the outside's derivative, the box kept, times the box's derivative.

Three functions stacked inside each other? Peel them one at a time, from the outside in. Take e to the sine of four x. An e on the outside, a sine in the middle, and four x deep inside. Peel the e first.

It stays e to the sine of four x, unchanged. Step in and peel the sine. That gives cosine of four x, with four x kept inside. The core, four x, gives four. Now multiply all three links: e to the sine four x, times cosine four x, times four.

So y prime is four cosine four x, times e to the sine four x. Link times link times link: that's why it's called a chain.

Any base a

The chain rule also shows where the a to the x rule comes from, for any positive base a. Rewrite it with base e. e and natural log undo each other, so a to the x is e to the natural log of a to the x. In the log of a power, the exponent hops to the front. So a to the x is e to the x natural log a.

Now it's e to an inside. The outside stays, e to the x natural log a... times the inside's derivative, natural log a, because the inside is just x times that number. Put a to the x back: the derivative of a to the x is a to the x, times natural log a.

Watch this part of the concept lesson

Read the rest of this scene

For example, two to the x gives two to the x, times natural log two. Quick check: what if a is e? Natural log e is one, so e to the x stays e to the x. It fits. New today: logs of any base. Log base a of x is natural log x over natural log a, for a positive base other than one.

That's the change-of-base formula, so its derivative is one over x natural log a. So log base two of x gives one over x natural log two.

Example 1: a square root

Example one. f of x is the square root of x squared plus five. Find f prime of x, then the tangent line at x equals two. The plan: this is a composite. The outside is a square root. The inside is x squared plus five, because you'd compute that first.

So, the chain rule.

Watch this part of the concept lesson

Read the rest of this scene

Part a. Calculus likes powers better than roots, so write it as a power: x squared plus five, to the one half. The outside's derivative: one half, times x squared plus five, to the negative one half. The inside stays as it is. And don't stop writing yet: times the inside's derivative, two x. On a free response, write the whole line, times two x included.

The negative one half power sends the root downstairs: two x over two root x squared plus five. The twos cancel... x over root x squared plus five. You've got f prime now. Try part b, the tangent line at x equals two, before I do. Part b. A tangent line needs two things: a point, f of two, and a slope, f prime of two.

First the point. Plug two into f: root of two squared plus five... root nine, three. Then the slope. Plug two into f prime: two over root nine... two thirds. Put the point and the slope together. So here is our line: y equals three, plus two thirds, times x minus two.

No need to simplify it. In the picture, the line touches the curve at two, three. There's one just like it in your workbook: catch the inside's derivative before you check the solution.

Common mistake: the inside's derivative

Back to part a for a moment, because this is where people lose points. On the 2025 AP exam, free-response question five began with the derivative of e to an inside, and the first point was for that derivative itself: an answer alone could not earn it. Now our part a. Here's where it goes wrong: f prime of x equals one half, x squared plus five, to the negative one half... and it stops. Then f prime of two comes out one sixth.

The outside's derivative is only half the job.

Watch this part of the concept lesson

Read the rest of this scene

Every time you finish an outside, ask: times what? Times the inside's derivative, two x. So f prime of x is x over root x squared plus five, and f prime of two is two thirds.

Example 2: product and chain

Example two. h of x is x squared, times e to the negative three x. Where does its graph have a horizontal tangent line? The plan: a horizontal tangent means slope zero, so we solve h prime of x equals zero. Looks busy? It's just a product, x squared times e to the negative three x, with a chain inside, e to the negative three x. The two rules sit right under the problem.

Knock out the chain first: e to the negative three x stays, times the inside's derivative, negative three.

Watch this part of the concept lesson

Read the rest of this scene

Now the product rule: two x, times e to the negative three x... plus x squared, times negative three e to the negative three x. To set it equal to zero, factor. Don't divide by x: that throws away the solution x equals zero. Pull out x, e to the negative three x. What's left: two minus three x.

Can e to the negative three x ever be zero? No. e to any power is positive. So x is zero, or two minus three x is zero: x equals two thirds. So x is zero or two thirds. That's C. Choice D, zero and negative two, is what you get when the negative three goes missing: two plus x instead of two minus three x.

Classic trap: the inside's derivative, dropped. Your turn: there's one like this in your workbook, a product with a chain inside. Write every factor out.

Example 3: three layers

Example three. f of x is sine squared of three x. Find f prime of pi over twelve. The chain rule and its shapes are under the problem. First, rewrite that floating two: sine squared of three x means sine of three x, all squared.

Looks scary? It's three short links: the square, the sine, and three x.

Watch this part of the concept lesson

Read the rest of this scene

Peel them. The square gives two sine three x, the sine gives cosine three x, and the inside gives three. Two times three: six sine three x cosine three x. Now x is pi over twelve. Multiply by three first: three x is pi over four. Everybody's favorite angle.

Sine of pi over four is root two over two. Cosine, the same. Six, times root two over two, times root two over two... six times two fourths. Three. So the answer is C. One more like this in your workbook.

Peel it one link at a time.

Worked examples

Example 1

Let f(x)=x2+5.
(a) Find f′(x).
(b) Write an equation of the tangent line to the graph of f at x=2.
Hint

Outside , inside x2+5.

Answer and solution
  1. f′(x)=xx2+5
  2. y=3+23(x−2)
  1. f(x)=(x2+5)12,f′(x)=12(x2+5)−12⋅2x=xx2+5
  2. f(2)=9=3,f′(2)=23
  3. Tangent line: y = 3 + (2/3)(x - 2).

Example 2

Let h(x)=x2e−3x. At which x-values does the graph of h have a horizontal tangent line?
  1. 0 only
  2. 23 only
  3. 0 and 23
  4. 0 and −2
Hint

Horizontal means h′(x)=0.

Answer and solution

Answer C. 0 and 23

  1. h′(x)=2xe−3x+x2⋅(−3e−3x)=xe−3x(2−3x)
  2. e^(-3x) > 0, never 0. So x = 0 or 2 - 3x = 0, x = 2/3. Answer C.

Example 3

If f(x)=sin2(3x), then f′(π12) =
  1. 1
  2. 32
  3. 3
  4. 32
Hint

Three layers: [sin(3x)]2.

Answer and solution

Answer C. 3

  1. f′(x)=2sin(3x)⋅cos(3x)⋅3=6sin(3x)cos(3x)
  2. f′(π12)=6⋅22⋅22=3
  3. x = pi/12 makes 3x = pi/4. Answer C.

Workbook

Problem 1

Find the derivative of each function. (a) y=(4x−1)5 (b) y=ex2−3x (c) y=sin(x3)
Hint

Outside first, then times the inside's derivative: 4, 2x−3, 3x2.

Answer and solution
  1. 5(4x−1)4⋅4=20(4x−1)4
  2. (2x−3)ex2−3x
  3. 3x2cos(x3)
  1. (a) Outside: the 5th power; inside 4x - 1 (inside' = 4). 5(4x - 1)^4 * 4 = 20(4x - 1)^4.
  2. (b) Outside: e to a power, kept as it is; inside x^2 - 3x. e^{x^2 - 3x}(2x - 3).
  3. (c) Outside: sine; inside x^3. cos(x^3) * 3x^2 = 3x^2 cos(x^3).

Common mistake Leaving out the inside's derivative: 5(4x - 1)^4, e^{x^2-3x}, cos(x^3).

Watch the worked solution to Problem 1

Problem 2

Let f(x)=6x−2. (a) Find f′(3). (b) Write an equation of the line tangent to the graph of f at x=3.
Hint

f′(x)=626x−2. The point is (3,f(3))=(3,4).

Answer and solution
  1. f′(3)=34
  2. y=4+34(x−3)
  1. f′(x)=12(6x−2)−12⋅6=36x−2
  2. f′(3)=316=34
  3. (b) The point: f(3) = sqrt(16) = 4. The tangent line is y = 4 + (3/4)(x - 3).

Common mistake Writing 1/(2 sqrt(6x - 2)) without the inside's 6; using f'(3) as the height of the line.

Watch the worked solution to Problem 2

Problem 3

Find the slope of each graph at the given x. (a) y=log3(2x+1) at x=1 (b) y=log2(x2+4) at x=2
Hint

ddxlogau=u′ulna. Keep the lna.

Answer and solution
  1. 23ln3
  2. 12ln2
  1. ddxlog3(2x+1)=2(2x+1)ln3→23ln3
  2. ddxlog2(x2+4)=2x(x2+4)ln2→48ln2=12ln2

Common mistake Dropping the ln a: 2/3 instead of 2/(3 ln 3).

Watch the worked solution to Problem 3

Problem 4

If f(x)=1+e2x, then f′(0)=
  1. 24
  2. 22
  3. 2
  4. 2
Hint

Three layers: the root, 1+e2x, and 2x. Peel one link at a time.

Answer and solution

Answer B. 22

  1. f′(x)=12(1+e2x)−12⋅e2x⋅2=e2x1+e2x
  2. f′(0)=12=22
  3. Answer B.

Common mistake Peeling only two of the three layers: the 2 from 2x is lost.

Watch the worked solution to Problem 4

Problem 5

If k(x)=ln(x2+3x), then k′(1)=
  1. 15
  2. 14
  3. 54
  4. 5
Hint

ddxlnu=u′u with u=x2+3x.

Answer and solution

Answer C. 54

  1. k′(x)=1x2+3x⋅(2x+3)=2x+3x2+3x
  2. k′(1)=54
  3. Answer C.

Common mistake Writing 1/(x^2 + 3x) without the top 2x + 3, giving 1/4.

Watch the worked solution to Problem 5

Problem 6

If f(x)=23x, then f′(1)=
  1. 12
  2. 24
  3. 8ln2
  4. 24ln2
Hint

x is in the exponent: ddx2u=2uln2⋅u′.

Answer and solution

Answer D. 24ln2

  1. f′(x)=23xln2⋅3
  2. f′(1)=23⋅ln2⋅3=24ln2
  3. Answer D.

Common mistake Using the power rule on 2^{3x}, or losing the inside 3.

Watch the worked solution to Problem 6

Problem 7

The temperature of a cup of coffee is T(t)=20+60e−t10 degrees Celsius, where t is measured in minutes.
  1. Find T′(t).
  2. Find T′(10). Using correct units, explain its meaning.
  3. At what time t is the coffee cooling at a rate of 3 degrees Celsius per minute?
Hint

The inside is −t10, with derivative −110. A rate needs its units.

Answer and solution
  1. T′(t)=60e−t10⋅(−110)=−6e−t10
  2. T′(10)=−6e degrees Celsius per minute: at t=10 minutes the temperature is decreasing at 6e≈2.2 degrees Celsius per minute
  3. −6e−t10=−3, e−t10=12, t=10ln2 minutes
  1. T′(t)=60e−t10⋅(−110)=−6e−t10
  2. (b) T'(10) = -6e^{-1} = -6/e degrees Celsius per minute: at 10 minutes the temperature is decreasing at 6/e degrees Celsius per minute.
  3. (c) Cooling at 3 means T′(t)=−3: e−t10=12, so t=10ln2 minutes.

Common mistake Losing the -1/10 from the exponent, or a rate without units.

Watch the worked solution to Problem 7

Problem 8

A rider on a Ferris wheel is h(t)=30−25cos(πt4) feet above the ground, where t is measured in minutes.
  1. Find h′(2). Using correct units, explain its meaning.
  2. At t=6, is the rider rising or falling? Give a reason.
  3. For 0<t<8, find the time at which h′(t)=0.
Hint

The inside πt4 gives a factor π4. Rising or falling is the sign of h′.

Answer and solution
  1. h′(2)=25π4 feet per minute: at t=2 minutes the rider is rising at 25π4 feet per minute
  2. falling, because h′(6)=−25π4<0
  3. t=4 minutes (sinπt4=0)
  1. h′(t)=25sin(πt4)⋅π4=25π4sin(πt4)
  2. (a) h'(2) = 25pi/4 feet per minute: at 2 minutes the rider is rising at 25pi/4 feet per minute.
  3. (b) h'(6) = (25pi/4) sin(3pi/2) = -25pi/4 < 0, so the rider is falling. (c) sin(pi t/4) = 0 with 0 < t < 8: pi t/4 = pi, t = 4.

Common mistake Losing the π/4 from the inside, or the sign of the derivative of cos.

Watch the worked solution to Problem 8

Problem 9

Let k(x)=(x−1)e2x. At which x-value does the graph of k have a horizontal tangent line?
  1. 0
  2. 12
  3. 1
  4. 2
Hint

Product rule, with a chain in e2x. Factor out e2x; it is never 0.

Answer and solution

Answer B. 12

  1. k′(x)=1⋅e2x+(x−1)⋅2e2x=e2x(2x−1)
  2. e^{2x} is never 0, so 2x - 1 = 0 and x = 1/2. Answer B.

Common mistake Dropping the chain's 2 in e^{2x}, giving x = 0.

Watch the worked solution to Problem 9