The chain rule is simple once a composite function has been read correctly. Most mistakes happen before the differentiation begins. A student sees several operations in one expression but does not identify which function is inside which, and the useful habit is to read the layers first.

The rule

Suppose \(g\) is differentiable at \(x\), and \(h\) is differentiable at \(g(x)\). Then

\[(h\circ g)'(x) = h'(g(x))g'(x)\]

The two derivatives are evaluated at different inputs. The inner derivative \(g'(x)\) is evaluated at \(x\), and the outer derivative \(h'\) is evaluated at the value produced by the inner function, \(g(x)\).

In Leibniz notation, if \(u=g(x)\), then \(\tfrac{dy}{dx} = \tfrac{dy}{du}\,\tfrac{du}{dx}\). This notation is useful, but the symbols should not be treated as ordinary fractions. The underlying statement is the composition rule above.

For example, consider \((3x+1)^5\). The outer function is \(h(u)=u^5\) and the inner function is \(g(x)=3x+1\), so \(h'(u)=5u^4\) and \(g'(x)=3\), which gives

\[\frac{d}{dx}(3x+1)^5 = 5(3x+1)^4\cdot3 = 15(3x+1)^4\]

The final answer must be written back in terms of \(x\).

Reading the layers

The visualization below lists the layers of several composite functions from outside to inside.

Seven composites. The stack lists the layers from the outside in; each row shows the factor that layer contributes and its value at the chosen x. The product row is the chain rule's answer, and the line beneath compares it against a slope measured directly from the function by a symmetric difference with a step of one hundred-thousandth. The two agree to four decimals at every position on the slider, for all seven functions, which is the point: the chain rule is not a mnemonic, it is a true statement about a number you could have measured instead.

Each layer contributes one factor to the derivative. For a two-layer composition \(h(g(x))\), the factors are \(h'(g(x))\) and \(g'(x)\). For a three-layer composition, the chain rule is simply applied again to the inner composition, and there is no separate three-layer rule.

The visualization also compares the chain-rule derivative with a numerically measured slope from the original function. The two values agree across the examples because the chain rule is describing the actual local rate of change, not merely a symbolic procedure.

Order matters

The functions \(\sin(x^2)\) and \((\sin x)^2\) contain the same two operations in opposite order, and their derivatives are different. For the first, \(\tfrac{d}{dx}\sin(x^2) = \cos(x^2)\cdot2x\), and for the second, \(\tfrac{d}{dx}(\sin x)^2 = 2\sin x\cos x\). The first function squares the input and then takes sine, while the second takes sine first and then squares the result.

A reliable way to identify the outermost operation is to ask what you would do last if you were evaluating the function at a number. For \(\sin(x^2)\), you square first and take sine last, so sine is the outer function. For \((\sin x)^2\), you take sine first and square last, so squaring is the outer function.

The missing inner factor

The most common chain-rule error is to differentiate the outer layer and stop. For \(\sin(x^2)\), that produces \(\cos(x^2)\), which is missing the derivative of the inner function, and the correct derivative is \(2x\cos(x^2)\). The size of the error changes with \(x\) because the missing factor is \(2x\).

The pattern of the error is more important than its size. If the derivative of the inside never appears, one layer has been dropped.

A rule can be valid without being useful

The chain rule applies to \((x^2)^3\), and using it gives \(3(x^2)^2\cdot2x = 6x^5\). But the original expression is simply \(x^6\), and the power rule gives \(6x^5\) immediately. So before applying the chain rule, simplify the expression if the composition can be collapsed cleanly.

The best rule is not always the most sophisticated rule available. It is the one that makes the structure easiest to see and the work easiest to check.