Calculus

The Chain Rule Explained So It Finally Makes Sense

Learn why rates multiply, how to spot inner and outer functions, and how to apply the chain rule without dropping a factor.

Key takeaways

  • A composite function f(g(x)) has derivative f′(g(x)) · g′(x): outer rate at the inner value, times inner rate.
  • To find the layers, ask which operation you would perform last if you computed the function by hand; that is the outermost one.
  • With three or more layers you keep multiplying, one factor for each layer, working from the outside in.
  • The most common error is stopping early and leaving out the derivative of the inside.
  • The rule requires g to be differentiable at x and f to be differentiable at g(x).

The chain rule tells you how to differentiate a function that sits inside another function. You take the derivative of the outer function, leaving the inside untouched, and then multiply by the derivative of the inside.

The reason is that rates of change multiply. If one quantity changes 3 times as fast as a middle quantity, and the middle quantity changes 2 times as fast as your input, then the first quantity changes 6 times as fast as the input. Everything else is bookkeeping about where to evaluate each rate.

Rates that multiply

Picture three gears in a row. Suppose the first turns the second so that the second spins twice for every turn of the first. The second turns a third so that the third spins three times for every turn of the second. Without any calculus, you can see that one turn of the first gear produces six turns of the third.

A derivative is a rate of change at a single point, as described in the derivative as an instantaneous rate of change. Near any one point, a smooth function behaves almost like a gear with a fixed ratio: a small change in input is multiplied by the derivative to give the change in output.

When two functions are chained, a small change in x is first multiplied by one local ratio and then by another. In Leibniz notation, with u as the middle quantity, the rule reads:

dy/dx = (dy/du) · (du/dx)

The symbols look like fractions that cancel. That is a helpful memory aid, although dy/du is defined as a limit and the cancellation is not by itself a proof.

Finding the inside and the outside

A composite function is one built by feeding the output of one function into another. Before you can use the rule, you need to see those layers.

A reliable test is to imagine computing the value with a calculator for a specific x. The last operation you perform is the outer function. Whatever you computed before it is the inside.

Function Inside u Outer function
(3x² + 1)⁵ 3x² + 1 u⁵
sin(x²) x² sin u
sin² x sin x u²
√(1 + 4x) 1 + 4x √u
e^(−x²/2) −x²/2 e^u

Notice the second and third rows. They use the same ingredients, squaring and sine, in opposite order. In sin(x²) you square first and take the sine last. In sin² x, which means (sin x)², you take the sine first and square last. Their derivatives are quite different.

Applying the chain rule
1 Find the last operation That is the outer function 2 Name the inside u Everything the outer function acts on 3 Differentiate the outside Keep u unchanged inside it 4 Multiply by du/dx Repeat if u has layers of its own Find the last operation That is the outer function 1 Name the inside u Everything the outer function acts on 2 Differentiate the outside Keep u unchanged inside it 3 Multiply by du/dx Repeat if u has layers of its own 4

Worked examples with one inner layer

Start with y = (3x² + 1)⁵. The outer function is u⁵, whose derivative is 5u⁴. The inside has derivative 6x.

dy/dx = 5(3x² + 1)⁴ · 6x      outer rate times inner rate
      = 30x(3x² + 1)⁴         tidy the constants

Now compare the two sine examples:

d/dx sin(x²)  = cos(x²) · 2x
d/dx (sin x)² = 2 sin x · cos x

For a square root, write it as a power if that helps. The derivative of √u is 1/(2√u), so for x > −1/4:

d/dx √(1 + 4x) = 1/(2√(1 + 4x)) · 4 = 2/√(1 + 4x)

Exponentials are especially friendly because e^u is its own derivative with respect to u:

d/dx e^(−x²/2) = e^(−x²/2) · (−x)

For a logarithm, the outer derivative is 1/u. On an interval where cos x is positive, d/dx ln(cos x) = (1/cos x) · (−sin x) = −tan x. More cases like these appear in derivatives of exponential and logarithmic functions.

Several layers at once

Some functions are nested three or four deep. The rule does not change; you simply keep going until you reach plain x.

Take y = cos³(5x), which means (cos(5x))³. Reading from the outside, you have a cube, then a cosine, then multiplication by 5.

cube:       3 (cos 5x)²
cosine:     −sin 5x
inside 5x:  5
product:    dy/dx = −15 cos²(5x) sin(5x)

Each layer contributes exactly one factor, and each factor is evaluated at whatever sits inside that layer. The cube's derivative still contains cos 5x, and the cosine's derivative still contains 5x. Never differentiate the inside while it is still sitting inside another function's derivative. Writing 3(−sin 5x)² would be wrong, because it changes the argument of the outer derivative.

If you lose track, introduce letters. Let w = 5x, v = cos w and y = v³. Then dy/dx = (dy/dv)(dv/dw)(dw/dx), and you can compute the three pieces separately before substituting back.

Mixing it with the product rule

Real problems often combine rules. The key is to ask the same question again: what is the last operation? If it is a multiplication, start with the product rule and use the chain rule inside it. The reasoning behind that companion rule is covered in the product and quotient rules.

For y = x² sin(3x), the last operation multiplies x² by sin(3x):

dy/dx = 2x · sin(3x) + x² · 3 cos(3x)

For y = x(2x − 1)⁴, the same pattern gives a result worth factoring:

dy/dx = (2x − 1)⁴ + x · 4(2x − 1)³ · 2
      = (2x − 1)³ (2x − 1 + 8x)
      = (2x − 1)³ (10x − 1)

Factoring is not required for correctness, but it makes later work much easier, such as finding where the derivative equals zero.

Why the rule is true

Here is the idea behind the proof. If g is differentiable at x, then a small step h changes the inside by approximately k = g′(x) · h. If f is differentiable at u = g(x), then a step k in u changes the output by approximately f′(u) · k. Substituting the first into the second, the output changes by about f′(g(x)) · g′(x) · h. Divide by h and let h shrink to zero.

A tempting shortcut writes the difference quotient as (Δy/Δu)(Δu/Δx) and takes limits. It works in many cases, but it breaks down if Δu equals zero for steps arbitrarily close to the point, since you cannot divide by zero. Rigorous proofs avoid that division by writing the change in f as (f′(u) + error) · Δu, where the error goes to zero as Δu does. That equation remains true even when Δu = 0.

You can also test a result numerically. At x = 1, the derivative of (3x² + 1)⁵ should be 30 · 4⁴ = 7680. The function equals 1024 at x = 1, so at x = 1.001 you expect roughly 1024 + 7.68 = 1031.68. A calculator gives a value very close to that, slightly higher because the curve bends upward.

Working from a table instead of a formula

The chain rule does not need formulas at all, only values and slopes. Suppose all you know about two differentiable functions is that g(2) = 5, g′(2) = −3 and f′(5) = 4. For h(x) = f(g(x)):

h′(2) = f′(g(2)) · g′(2) = f′(5) · (−3) = 4 · (−3) = −12

Notice that f′ is evaluated at 5, the output of g, and not at 2. If a problem also told you f′(2), that number would be a distraction. This kind of question tests whether you understand where each rate is measured.

The same reasoning handles units. Say the area of a spreading circular stain depends on its radius, and the radius depends on time. At a moment when the radius is 3 cm and growing at 0.5 cm per second, the area changes at 2π · 3 · 0.5 = 3π, or about 9.4 cm² per second. The units confirm the structure: cm² per cm, multiplied by cm per second, gives cm² per second. When the units of your factors do not combine into the units of the answer, a factor is missing or misplaced.

Mistakes that cost the most points

  • Forgetting the inner derivative. Writing d/dx sin(x²) = cos(x²) leaves out the factor 2x.
  • Differentiating both layers at once. The derivative of sin(x²) is not cos(2x). The outer derivative keeps the original inside.
  • Using the chain rule on a product. x² sin x is not a composition; it needs the product rule.
  • Confusing powers. sin² x and sin(x²) are different functions.
  • Ignoring domains. The square root and logarithm examples only make sense where their insides are allowed.

A quick habit prevents most of these. After differentiating, count the layers in the original function and count the factors in your answer that came from them. If a function had three layers, you should be able to point to three factors, even if some were constants that you later combined. More traps of this kind are collected in common calculus mistakes.

Where the chain rule goes next

The chain rule is behind a surprising share of calculus. When an equation mixes x and y and you cannot or do not want to solve for y, you treat y as an inside function; that is implicit differentiation. When several quantities all change with time, the chain rule links their rates, which is the heart of related rates problems.

Run backward, it becomes integration by substitution: you look for an inside function whose derivative also appears in the integrand. In several variables, a version of the rule adds up one product for each path from the input to the output, and the same bookkeeping, applied on a very large scale, is used to train neural networks.

For practice, pick any function with at least two layers, differentiate it, and then compare your answer at one point with a numerical estimate using a tiny step. If the two disagree by more than rounding explains, look first for a missing factor.

Written for 4Mathematics with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 39 articles in Calculus →

Latest news on this topic