Skip to content

The Chain Rule Explained with Examples

Learn the chain rule step by step with clear, fully worked examples. Master derivatives of composite functions with our free calculus solver and tips.

If you have ever tried to take the derivative of something like \( (3x+1)^5 \) or \( \sin(x^2) \) and felt stuck, you are not alone. These are composite functions — functions tucked inside other functions — and the ordinary power rule or trig rules alone will not finish the job. The tool you need is the chain rule, one of the most important and most used techniques in all of calculus.

In this guide you will learn exactly what the chain rule is, when to reach for it, and how to apply it with confidence. We will build an easy step-by-step recipe, walk through several fully worked examples (showing every line of work), highlight the mistakes students make most often, and give you a quick-reference table you can keep nearby. If you ever want to check an answer or see the steps for your own problem, you can run it through our calculus solver in seconds.

This article is written for students from middle school explorers through early-college calculus learners, as well as parents helping at the kitchen table. No fancy jargon, no skipped steps — just a clear path to understanding. Let us dive in.

What Is the Chain Rule?

The chain rule is a formula for finding the derivative of a composite function — a function made by plugging one function into another. If you can write a function as an “outside” function wrapped around an “inside” function, the chain rule tells you how fast the whole thing changes.

Suppose we have a function written as \( h(x) = f(g(x)) \). Here \( f \) is the outer function and \( g \) is the inner function. The chain rule says:

$$ h'(x) = f’\big(g(x)\big) \cdot g'(x) $$

In plain English: take the derivative of the outside (leaving the inside alone), then multiply by the derivative of the inside. That single sentence is the heart of everything below.

Key idea

Differentiate the outer function first while keeping the inside untouched, then multiply by the derivative of the inner function. Outside, then inside, then multiply.

Two Ways to Write the Same Rule

You will see the chain rule written in two notations, and they mean the same thing.

Lagrange (prime) notation:

$$ \big(f(g(x))\big)’ = f'(g(x)) \cdot g'(x) $$

Leibniz notation: if \( y = f(u) \) and \( u = g(x) \), then

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

The Leibniz version is helpful because it looks like fractions “canceling”: the \( du \) on the bottom of the first piece and the \( du \) on top of the second piece remind you that the rates of change multiply together. That mental picture is exactly why some teachers call it the “chain” rule — you are linking rates of change like links in a chain.

When Do You Need the Chain Rule?

You need the chain rule whenever there is a function inside another function. A quick test: ask yourself, “Is there something more complicated than a plain \( x \) sitting where the variable would normally be?” If yes, you almost certainly have a composite function.

  • \( (2x+7)^4 \) — a polynomial \( 2x+7 \) sits inside a power.
  • \( \sin(5x) \) — the expression \( 5x \) sits inside the sine.
  • \( e^{x^2} \) — the expression \( x^2 \) sits inside the exponential.
  • \( \sqrt{x^2+1} \) — the expression \( x^2+1 \) sits inside a square root.
  • \( \ln(3x-4) \) — the expression \( 3x-4 \) sits inside the natural log.

By contrast, simple functions like \( x^3 \), \( \sin x \), or \( e^x \) have nothing but a plain \( x \) inside, so they do not require the chain rule — the basic rules from How to Find Derivatives: Rules and Examples are enough. Spotting the difference is the first skill to master.

A Simple Recipe for Using the Chain Rule

Here is a reliable five-step process that works for any composite function. Follow it the same way every time and the chain rule becomes almost mechanical.

  1. Identify the inside and the outside. Decide which part is the inner function \( g(x) \) and which is the outer function \( f \). The inside is usually the expression “wrapped” by a power, root, trig function, exponential, or log.
  2. Differentiate the outside, keeping the inside frozen. Apply the derivative rule for the outer function, but leave the inner expression exactly as it is.
  3. Differentiate the inside. Find \( g'(x) \) on its own.
  4. Multiply. Multiply your two results together: outer derivative times inner derivative.
  5. Simplify. Combine constants and tidy the expression so the final answer is clean.

Study tip

A handy mental phrase is “derivative of the outside, times the derivative of the inside.” Say it out loud while you work the first few problems. The rhythm trains your brain to never forget the second factor — the part students most often drop.

Worked Examples of the Chain Rule

Now for the part that makes everything click: complete examples with every step shown. Work through them slowly and try to predict the next line before you read it.

Example 1: A Power of a Linear Expression

Differentiate \( h(x) = (3x + 1)^5 \).

Step 1 — Identify inside and outside. The inside is \( g(x) = 3x + 1 \). The outside is the fifth power, \( f(u) = u^5 \).

Step 2 — Differentiate the outside. Using the power rule on \( u^5 \) gives \( f'(u) = 5u^4 \). Keeping the inside frozen, this becomes \( 5(3x+1)^4 \).

Step 3 — Differentiate the inside. The derivative of \( 3x + 1 \) is \( g'(x) = 3 \).

Step 4 — Multiply.

$$ h'(x) = 5(3x+1)^4 \cdot 3 $$

Step 5 — Simplify. Combine the constants \( 5 \cdot 3 = 15 \).

Answer\( h'(x) = 15(3x+1)^4 \)

Notice what would happen if you forgot Step 3. You might write \( 5(3x+1)^4 \) and stop — but that is missing the factor of 3 from the inside. The chain rule exists precisely to capture that extra factor.

Example 2: A Trig Function with Something Inside

Differentiate \( h(x) = \sin(x^2) \).

Step 1 — Identify inside and outside. The inside is \( g(x) = x^2 \). The outside is \( f(u) = \sin u \).

Step 2 — Differentiate the outside. The derivative of \( \sin u \) is \( \cos u \), so keeping the inside frozen we get \( \cos(x^2) \).

Step 3 — Differentiate the inside. The derivative of \( x^2 \) is \( g'(x) = 2x \).

Step 4 — Multiply.

$$ h'(x) = \cos(x^2) \cdot 2x $$

Step 5 — Simplify. Write the constant factor in front for a tidy result.

Answer\( h'(x) = 2x\cos(x^2) \)

Common mistake

Do not confuse \( \sin(x^2) \) with \( \sin^2(x) \). They are different functions! In \( \sin(x^2) \) the inside is \( x^2 \). In \( \sin^2(x) = (\sin x)^2 \) the inside is \( \sin x \). Each still uses the chain rule, but the inner and outer pieces are not the same.

Example 3: A Square Root (Radical)

Differentiate \( h(x) = \sqrt{x^2 + 1} \).

Step 0 — Rewrite the root as a power. A square root is the \( \tfrac{1}{2} \) power, so write

$$ h(x) = (x^2 + 1)^{1/2} $$

Step 1 — Identify inside and outside. Inside: \( g(x) = x^2 + 1 \). Outside: \( f(u) = u^{1/2} \).

Step 2 — Differentiate the outside. By the power rule, \( f'(u) = \tfrac{1}{2}u^{-1/2} \). Freezing the inside gives \( \tfrac{1}{2}(x^2+1)^{-1/2} \).

Step 3 — Differentiate the inside. The derivative of \( x^2 + 1 \) is \( g'(x) = 2x \).

Step 4 — Multiply.

$$ h'(x) = \tfrac{1}{2}(x^2+1)^{-1/2} \cdot 2x $$

Step 5 — Simplify. The \( \tfrac{1}{2} \) and the \( 2 \) cancel, and a negative exponent moves the term to the denominator:

$$ h'(x) = \frac{2x}{2\sqrt{x^2+1}} = \frac{x}{\sqrt{x^2+1}} $$
Answer\( h'(x) = \dfrac{x}{\sqrt{x^2+1}} \)

Rewriting roots and fractions as powers before you differentiate is a small habit that prevents a lot of confusion. Once it is a power, the chain rule applies the same way every time.

Example 4: Two Layers Deep (the Chain Rule Used Twice)

Sometimes a function has a function inside a function inside another function. The chain rule still works — you just apply it more than once, peeling off one layer at a time.

Differentiate \( h(x) = e^{\sin(3x)} \).

Step 1 — Identify the layers. From the outside in: the outermost is the exponential \( e^{(\,\cdot\,)} \); the middle is \( \sin(\,\cdot\,) \); the innermost is \( 3x \).

Step 2 — Differentiate the outermost layer. The derivative of \( e^{u} \) is \( e^{u} \), so we keep the rest frozen: \( e^{\sin(3x)} \).

Step 3 — Multiply by the derivative of the next layer. The derivative of \( \sin(3x) \) with respect to its inside is \( \cos(3x) \).

Step 4 — Multiply by the derivative of the innermost layer. The derivative of \( 3x \) is \( 3 \).

Chaining all three factors together:

$$ h'(x) = e^{\sin(3x)} \cdot \cos(3x) \cdot 3 $$

Step 5 — Simplify. Put the constant out front.

Answer\( h'(x) = 3\cos(3x)\,e^{\sin(3x)} \)

The pattern for nested functions is wonderfully consistent: differentiate each layer from the outside in, and multiply all the pieces together. Two layers means two factors after the outermost derivative; three layers means three. The chain never breaks.

Example 5: A Natural Logarithm

Differentiate \( h(x) = \ln(5x^2 + 2) \).

Step 1 — Identify inside and outside. Inside: \( g(x) = 5x^2 + 2 \). Outside: \( f(u) = \ln u \).

Step 2 — Differentiate the outside. The derivative of \( \ln u \) is \( \dfrac{1}{u} \), so keeping the inside frozen gives \( \dfrac{1}{5x^2+2} \).

Step 3 — Differentiate the inside. The derivative of \( 5x^2 + 2 \) is \( g'(x) = 10x \).

Step 4 — Multiply.

$$ h'(x) = \frac{1}{5x^2+2} \cdot 10x $$

Step 5 — Simplify.

Answer\( h'(x) = \dfrac{10x}{5x^2+2} \)

Logarithm problems show off the chain rule beautifully: the derivative is the derivative of the inside divided by the inside itself, which is just the formula \( \tfrac{1}{g(x)} \cdot g'(x) \) written as a single fraction.

Want to check your work?

Type any composite function into our step-by-step derivative calculator and compare your steps with the worked solution. It is a fast, judgment-free way to catch a dropped factor or a sign error before it becomes a habit.

A Quick-Reference Table of Chain Rule Patterns

Once you have done a handful of problems, you will start to recognize patterns. This table summarizes the most common outer functions and how the chain rule transforms them. In every row, \( g(x) \) is the inner function and \( g'(x) \) is its derivative.

Function \( h(x) \)Derivative \( h'(x) \)
\( \big(g(x)\big)^n \)\( n\big(g(x)\big)^{n-1} \cdot g'(x) \)
\( \sin\big(g(x)\big) \)\( \cos\big(g(x)\big) \cdot g'(x) \)
\( \cos\big(g(x)\big) \)\( -\sin\big(g(x)\big) \cdot g'(x) \)
\( \tan\big(g(x)\big) \)\( \sec^2\big(g(x)\big) \cdot g'(x) \)
\( e^{\,g(x)} \)\( e^{\,g(x)} \cdot g'(x) \)
\( \ln\big(g(x)\big) \)\( \dfrac{g'(x)}{g(x)} \)
\( \sqrt{g(x)} \)\( \dfrac{g'(x)}{2\sqrt{g(x)}} \)

Each formula is just the general chain rule with a specific outer function plugged in. If you ever forget a row, you can rebuild it from the basic recipe — outside, inside, multiply.

Common Mistakes to Avoid

The chain rule is not hard, but a few predictable slips trip students up again and again. Watch out for these.

Mistake 1: Forgetting to multiply by the inside derivative

Writing the derivative of \( (3x+1)^5 \) as \( 5(3x+1)^4 \) and stopping is the single most common error. You must still multiply by \( g'(x) = 3 \). The missing factor is the whole point of the rule.

Mistake 2: Differentiating the inside too early

When you take the derivative of the outside, the inside stays exactly as it was. For \( \sin(x^2) \), the first factor is \( \cos(x^2) \), not \( \cos(2x) \). Change the inside only in the separate factor \( g'(x) \).

Mistake 3: Losing track of layers

With nested functions like \( e^{\sin(3x)} \), it is easy to forget the innermost factor. Count your layers before you start, and make sure your answer has one factor for each layer.

Combining the Chain Rule with Other Rules

In real problems, the chain rule rarely shows up alone. You will often combine it with the product rule or quotient rule. The key is to recognize which rule governs the overall structure, then apply the chain rule on any composite piece inside.

For example, to differentiate \( y = x^2 (2x+1)^3 \), you treat it as a product of \( x^2 \) and \( (2x+1)^3 \). The product rule handles the overall shape, and the chain rule handles the derivative of \( (2x+1)^3 \), which is \( 3(2x+1)^2 \cdot 2 = 6(2x+1)^2 \). Putting it together:

$$ y’ = 2x(2x+1)^3 + x^2 \cdot 6(2x+1)^2 $$

If integration is your next topic, the reverse of the chain rule appears there too as a technique called \(u\)-substitution. You can see it in action in our guide to How to Solve Integrals: A Beginner’s Guide. And because every derivative rule rests on the idea of a limit, it is worth strengthening that foundation with Understanding Limits in Calculus (with Worked Examples).

Why the Chain Rule Works (A Quick Intuition)

Here is the idea behind the formula, in everyday terms. Imagine a chain of effects: a small change in \( x \) causes a change in the inside function \( g \), and that change in \( g \) then causes a change in the outside function \( f \). To find the total rate of change of the output with respect to \( x \), you multiply the rate at which \( f \) responds to \( g \) by the rate at which \( g \) responds to \( x \). That is exactly the Leibniz form:

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

Think of gears turning gears. If the first gear spins twice as fast as you turn the crank, and the second gear spins three times as fast as the first, then the second gear spins six times as fast as your hand — you multiply the rates. The chain rule is calculus capturing that same common-sense multiplication of rates.

Practice Problems to Try

Test yourself on these. Use the recipe, then verify each answer with our tool.

  • Differentiate \( (4x - 5)^6 \). (Answer: \( 24(4x-5)^5 \))
  • Differentiate \( \cos(7x) \). (Answer: \( -7\sin(7x) \))
  • Differentiate \( \sqrt{3x^2 + 2} \). (Answer: \( \dfrac{3x}{\sqrt{3x^2+2}} \))
  • Differentiate \( e^{4x^3} \). (Answer: \( 12x^2 e^{4x^3} \))

For the first one: the outside derivative is \( 6(4x-5)^5 \), the inside derivative is \( 4 \), and \( 6 \cdot 4 = 24 \), giving \( 24(4x-5)^5 \). Walk through the others the same way, and you will see the recipe never changes.

Study tip

After you solve a problem by hand, run the same function through our calculus solver and read its steps line by line. Comparing your reasoning to a worked solution is one of the most effective ways to make a new rule stick.

Conclusion

The chain rule turns intimidating composite functions into routine, predictable work. Remember the one-line summary — differentiate the outside while keeping the inside frozen, then multiply by the derivative of the inside — and follow the five-step recipe every time. Identify the layers, differentiate the outer function, differentiate the inner function, multiply, and simplify. With a little practice, even three-layer functions like \( e^{\sin(3x)} \) become straightforward.

Ready to keep going? Put your own problems into our free calculus solver to see clear, step-by-step solutions, and explore more friendly guides on derivatives, integrals, and limits over on the Math Solver AI blog. The more you practice, the more the chain rule will feel like second nature.