practicecalculus
Derivatives

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
  1. What the chain rule says
  2. Why it works: rates multiply
  3. How to find the inside function
  4. Worked example 1: a power of a polynomial
  5. Worked example 2: a trig function
  6. Worked example 3: exponentials and logarithms
  7. Worked example 4: a square root
  8. Using the chain rule more than once
  9. Chain rule with the product rule
  10. Common chain rule mistakes
  11. Quick reference
  12. 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:

\frac{d}{dx}\, f(g(x)) = f'(g(x)) \cdot g'(x)

Read it as a recipe:

  1. Differentiate the outside function, but leave the inside exactly as it is.
  2. 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

\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}

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 of sin(x²) oscillates faster as x grows, because the inside function x² grows faster
y = \sin(x^2) wiggles faster and faster. Its slope is 2x\cos(x^2): the extra factor 2x comes from the inside function.

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.

\frac{dy}{dx} = 5(3x+1)^4 \cdot 3 = 15(3x+1)^4

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.
\frac{dy}{dx} = \cos(x^2) \cdot 2x = 2x\cos(x^2)

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:

\frac{dy}{dx} = 4e^{4x}

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:

\frac{dy}{dx} = \frac{1}{x^2+1} \cdot 2x = \frac{2x}{x^2+1}
The graph of ln(x² + 1) with its tangent line at x = 1
At x = 1 the slope of \ln(x^2+1) is \frac{2(1)}{1^2+1} = 1, so the tangent line is y = x - 1 + \ln 2.

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:

\frac{dy}{dx} = \tfrac{1}{2}(x^2+9)^{-1/2} \cdot 2x = \frac{x}{\sqrt{x^2+9}}

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.

  1. Outermost layer, the cube: 3\sin^2(2x).
  2. Middle layer, the sine: \cos(2x).
  3. Innermost layer, 2x: 2.
\frac{dy}{dx} = 3\sin^2(2x) \cdot \cos(2x) \cdot 2 = 6\sin^2(2x)\cos(2x)

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):

\frac{dy}{dx} = 2x\sin(3x) + x^2 \cdot 3\cos(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:

  1. 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.
  2. Changing the inside. Writing \frac{d}{dx}\sin(x^2) = \cos(2x). The inside stays the same inside the outer derivative.
  3. 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.
  4. 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

Frequently asked questions

What is the chain rule in simple terms?

The chain rule says that to differentiate a function inside another function, you take the derivative of the outside function (leaving the inside alone) and multiply it by the derivative of the inside. In symbols, \frac{d}{dx} f(g(x)) = f'(g(x)) \cdot g'(x).

How do I know when to use the chain rule?

Use it whenever something other than plain x sits inside a function: inside a power, a root, a trig function, an exponential or a logarithm. For example (3x+1)^5, \sin(x^2) and e^{4x} all need the chain rule, but x^5, \sin x and e^x do not.

What is the difference between the chain rule and the product rule?

The product rule is for two functions multiplied together, like x^2 \sin x. The chain rule is for one function inside another, like \sin(x^2). Some functions need both, such as x^2 \sin(3x).

Can you use the chain rule more than once?

Yes. If there are several layers, like \sin^3(2x), apply it once per layer and multiply all the derivatives together, working from the outside in.

Why does the chain rule work?

Rates of change multiply. If u changes 3 times as fast as x, and y changes 2 times as fast as u, then y changes 2 \cdot 3 = 6 times as fast as x. In Leibniz notation that is \frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}.

Written by the PracticeCalculus team

We build interactive calculus lessons and write every page to be clear and correct. Spotted something off? Tell us and we will fix it.