The chain rule
Statement
Let \( I, J \subseteq \mathbb{R} \) be open intervals, let \( g : I \to \mathbb{R} \) satisfy \( g(I) \subseteq J \), and let \( f : J \to \mathbb{R} \). Fix \( a \in I \) and write \( b = g(a) \in J \). If \( g \) is differentiable at \( a \) and \( f \) is differentiable at \( b = g(a) \), then the composition \( f \circ g : I \to \mathbb{R} \) is differentiable at \( a \), and \[ (f \circ g)'(a) \;=\; f'\big(g(a)\big)\cdot g'(a). \] All hypotheses are pointwise: nothing is assumed about \( f \) or \( g \) away from \( a \) and \( g(a) \) beyond their being defined on the stated open sets.
Why it matters
The chain rule is the engine that turns differentiation from a short table of facts into an algorithm. Together with linearity, the product rule and the derivatives of a handful of elementary functions, it closes the class of "differentiable-in-closed-form" functions under composition — which is why every function you can write down with formulas can be differentiated mechanically. Modern automatic differentiation (and hence the backpropagation algorithm underlying machine learning) is nothing but the chain rule applied systematically along a computation graph.
It is also the first theorem in analysis whose obvious proof is wrong. The tempting manipulation \( \frac{\Delta f}{\Delta x} = \frac{\Delta f}{\Delta g}\cdot\frac{\Delta g}{\Delta x} \) divides by \( \Delta g = g(x) - g(a) \), which may vanish for \( x \) arbitrarily close to \( a \). Repairing this gap (below, via Carathéodory's formulation of differentiability) is a genuine lesson in what a limit argument may and may not do.
Hypotheses
Proof
The proof runs through Carathéodory's lemma, which trades the difference quotient for a multiplicative identity valid even where increments vanish. We prove the direction of the lemma we use as Steps 1–2 rather than citing it.
Result
Reading. To first order, \( g \) magnifies displacements near \( a \) by the factor \( g'(a) \), and \( f \) magnifies displacements near \( g(a) \) by the factor \( f'(g(a)) \). Feeding the output of one into the other multiplies the magnifications. In Leibniz notation, with \( u = g(x) \): \( \dfrac{dy}{dx} = \dfrac{dy}{du}\cdot\dfrac{du}{dx} \), the derivative of the outer function being evaluated at the inner value \( u = g(x) \), never at \( x \).
Scope. Real-valued functions of one real variable, at interior points of their domains, with genuine two-sided derivatives at the two relevant points \( a \) and \( g(a) \). It is a pointwise theorem: no differentiability, continuity or monotonicity is needed anywhere else. It generalises verbatim to maps between open subsets of normed spaces with Fréchet derivatives (\( D(f\circ g)(a) = Df(g(a)) \circ Dg(a) \), composition of linear maps), and to holomorphic functions of a complex variable; it does not survive unmodified for one-sided derivatives or for derivatives at boundary points.
Corollaries & converses
- Reciprocal rule. If \( g \) is differentiable at \( a \) and \( g(a) \ne 0 \), then \( \left(\frac{1}{g}\right)'(a) = -\frac{g'(a)}{g(a)^2} \): apply the theorem with \( f(y) = 1/y \) on an interval excluding \( 0 \). Combined with the product rule this yields the quotient rule for free.
- Generalised power rule. \( \frac{d}{dx}\, g(x)^n = n\,g(x)^{n-1} g'(x) \) for \( n \in \mathbb{N} \) wherever \( g \) is differentiable, and for negative and rational exponents wherever the power is defined and differentiable.
- Scaling and translation. \( \frac{d}{dx} f(cx + d) = c\,f'(cx+d) \) — the workhorse of Fourier analysis and ODE substitutions.
- Inverse function formula (conditional). If \( f \) is invertible near \( b = f(a) \) and \( f^{-1} \) is known to be differentiable at \( b \), then differentiating \( f(f^{-1}(y)) = y \) by the chain rule forces \( (f^{-1})'(b) = 1/f'(a) \) and shows \( f'(a) \ne 0 \). The chain rule does not prove \( f^{-1} \) is differentiable — that is the separate inverse function theorem.
- Converse is false. Differentiability of \( f \circ g \) at \( a \) implies nothing about \( f \) or \( g \) separately: with \( f(y) = y^2 \) and \( g(x) = |x| \), the composite \( (f\circ g)(x) = x^2 \) is smooth at \( 0 \), yet \( g \) is not differentiable there. More brutally, if \( f \) is constant then \( f \circ g \) is differentiable for arbitrary (even nowhere-continuous) \( g \).
- No product-of-derivatives reading of the converse either. \( (f\circ g)'(a) = 0 \) does not force \( f'(g(a)) = 0 \) or \( g'(a) = 0 \) unless both derivatives exist — and when they do, it forces only that the product vanishes.
Fails without
- Drop differentiability of the outer function at the image point. \( f(y) = |y| \), \( g(x) = x \), \( a = 0 \): \( g \) is differentiable everywhere, but \( (f\circ g)(x) = |x| \) has no derivative at \( 0 \), and the formula \( f'(g(0))\,g'(0) \) is not even defined. Note the conclusion can also survive by accident when this hypothesis fails: with the same \( f \) and \( g(x) = x^2\sin(1/x) \), \( g(0) = 0 \), one checks \( (f\circ g)'(0) = 0 \) exists although \( f \) is not differentiable at \( g(0) = 0 \). Once a hypothesis fails, the theorem gives no verdict either way.
- Drop differentiability of the inner function. \( g(x) = |x| \), \( f(y) = y \), \( a = 0 \): \( f \) is everywhere differentiable, \( (f\circ g)(x) = |x| \) is not differentiable at \( 0 \).
- Drop two-sidedness (one-sided derivatives). \( f(y) = |y| \), \( g(x) = -x \), \( a = 0 \): all four one-sided derivatives exist, yet \( (f\circ g)'_+(0) = +1 \ne f'_+(g(0))\cdot g'_+(0) = -1 \). The one-sided chain rule needs an extra hypothesis (e.g. \( g \) maps a right-neighbourhood of \( a \) into a right-neighbourhood of \( g(a) \)).
- Drop the theorem and trust the naive proof. With \( g(x) = x^2\sin(1/x) \), \( g(0) = 0 \), \( a = 0 \), the increment \( g(x) - g(0) \) vanishes at \( x = 1/(n\pi) \) for every \( n \in \mathbb{N} \), so the manipulation \( \frac{\Delta(f\circ g)}{\Delta x} = \frac{\Delta f}{\Delta g}\cdot\frac{\Delta g}{\Delta x} \) divides by zero on a sequence converging to \( a \). The theorem is true here (its proof never divides by \( \Delta g \)); the naive argument is not a proof of it.
Common errors
- The forgotten inner derivative. Writing \( \frac{d}{dx}\sin(x^2) = \cos(x^2) \). The outer derivative alone is only the answer when the inner derivative is \( 1 \).
- Evaluating the outer derivative at the wrong point. Writing \( \frac{d}{dx}\sin(x^2) = \cos(x)\cdot 2x \). The derivative of the outer function must be evaluated at the inner value \( g(x) \), not at \( x \).
- The illegal division "proof". Multiplying and dividing the difference quotient by \( g(x) - g(a) \) without noticing this may be \( 0 \) for \( x \) arbitrarily close to \( a \). Any submitted proof must handle the case \( g(x) = g(a) \) — Carathéodory's function \( \varphi \) exists precisely to do so.
- Treating Leibniz cancellation as an argument. "\( \frac{dy}{du}\cdot\frac{du}{dx} = \frac{dy}{dx} \) because the \( du \)'s cancel" is a mnemonic, not a proof: \( \frac{dy}{du} \) is not a fraction of real numbers, and the mnemonic silently commits the illegal division above.
- Confusing \( (f\circ g)' \) with \( f' \circ g' \) or with \( f'g' \). The correct object is \( (f'\circ g)\cdot g' \): compose then multiply, with \( f' \) composed with \( g \) itself.
- Applying the formula at boundary points or with one-sided derivatives without checking that the inner function preserves the relevant side (see Hypotheses).
- Assuming failure of hypotheses means failure of the conclusion. \( x \mapsto (|x|)^2 = x^2 \) is differentiable at \( 0 \) although the inner function is not: the chain rule is a sufficient condition only.
Discussion
Historically the rule is as old as the calculus itself: Leibniz used it implicitly in a 1676 manuscript when differentiating \( \sqrt{a + bz + cz^2} \) by substitution, and it appears (without the modern name) in l'Hôpital's 1696 Analyse des infiniment petits. What is genuinely modern is the proof. Throughout the eighteenth and much of the nineteenth century the standard argument was the flawed division by \( \Delta g \); the gap was noticed and repaired only once Weierstrass-era rigour made pathological examples like \( x^2\sin(1/x) \) respectable objects rather than curiosities. The clean repair given above is usually credited to Constantin Carathéodory, whose 1950 textbook made "differentiable at \( b \) \( \iff \) the increment factors through a function continuous at \( b \)" the definition; Hardy's A Course of Pure Mathematics had earlier handled the degenerate case by an explicit case split.
The Leibniz notation \( \frac{dy}{dx} = \frac{dy}{du}\frac{du}{dx} \) survives because it is an outstanding piece of interface design: it makes the theorem look like algebra and makes iterated compositions (\( \frac{dy}{dx} = \frac{dy}{du}\frac{du}{dv}\frac{dv}{dx} \)) self-assembling. The cost is that students mistake the notation's suggestiveness for its justification. A useful discipline is to translate any Leibniz-notation computation back into the primed form \( (f\circ g)'(a) = f'(g(a))\,g'(a) \) at least once, checking where each derivative is evaluated.
The right way to see why the theorem is true is linear-approximation bookkeeping: differentiability at a point means the function is, to within an error vanishing faster than the displacement, a linear map on displacements. Composing "linear map plus small error" with "linear map plus small error" yields the composite linear map plus errors that stay small — the entire proof is an audit of those error terms (the Carathéodory argument is this audit in disguise). This viewpoint is the one that generalises: for \( g : U \subseteq \mathbb{R}^n \to \mathbb{R}^m \) and \( f : V \subseteq \mathbb{R}^m \to \mathbb{R}^k \), the chain rule reads \( D(f\circ g)(a) = Df(g(a)) \circ Dg(a) \), composition of the derivative linear maps, i.e. multiplication of Jacobian matrices; the one-variable product \( f'(g(a))g'(a) \) is the \( 1\times 1 \) case. In categorical language the derivative is functorial: it sends composition of pointed maps to composition of linear maps. Numerically, evaluating that composite product left-to-right rather than right-to-left is exactly the difference between forward- and reverse-mode automatic differentiation, and reverse mode is backpropagation.
In full generality, let \( X, Y, Z \) be normed spaces, \( U \subseteq X \), \( V \subseteq Y \) open, \( g : U \to V \), \( f : V \to Z \), with \( g \) Fréchet differentiable at \( a \) and \( f \) at \( g(a) \): then \( f \circ g \) is Fréchet differentiable at \( a \) with \( D(f\circ g)(a) = Df(g(a))\circ Dg(a) \). The proof is the little-\( o \) audit made precise: writing \( g(a+h) = g(a) + Dg(a)h + r(h) \) with \( \|r(h)\| = o(\|h\|) \) and \( f(b+k) = f(b) + Df(b)k + s(k) \) with \( \|s(k)\| = o(\|k\|) \), substitute \( k = Dg(a)h + r(h) \); boundedness of the linear map \( Dg(a) \) gives \( \|k\| = \mathcal{O}(\|h\|) \), whence \( Df(b)r(h) = o(\|h\|) \) and \( s(k) = o(\|h\|) \) — the only delicate point being that \( s(k) = o(\|k\|) \) must be converted to \( o(\|h\|) \) uniformly, which requires the \( \varepsilon \)-\( \delta \) form of the little-\( o \) hypothesis, not just sequential limits along \( k \ne 0 \). Note that in this setting there is no difference quotient at all — one cannot divide by a vector — so the Carathéodory/little-\( o \) formulation is not merely a fix for a degenerate case but the only available definition.
Common misconceptions. (i) "The chain rule fails for \( g(x) = x^2\sin(1/x) \) at \( 0 \)" — false; the naive proof fails there, the theorem holds and its conclusion is easily verified. (ii) "If \( f \circ g \) is differentiable then \( f \) and \( g \) must be" — false (see Corollaries). (iii) "The multivariable chain rule is a different theorem" — it is the same theorem about composing linear approximations; only the bookkeeping (matrices instead of numbers) changes. (iv) "\( \frac{dy}{du} \) means a fraction, so the rule is trivial" — the notation is a mnemonic; the content is the limit theorem proved above.
Worked examples
Example 1 (computational). Differentiate \( h(x) = \sin\!\left(x^3 + 2x\right) \) on \( \mathbb{R} \).
Reading. Outer derivative at the inner value, times inner derivative — the standard mechanical pattern.
Scope. Valid on all of \( \mathbb{R} \) since both hypotheses hold at every point.
Example 2 (structural). Let \( f : \mathbb{R} \to \mathbb{R} \) be differentiable and even: \( f(-x) = f(x) \) for all \( x \). Prove that \( f' \) is odd, and deduce \( f'(0) = 0 \).
Reading. Reflecting the input reverses the sign of the slope: the graph of an even function has mirror-image tangents, so the tangent at \( 0 \) must be its own mirror image — horizontal.
Scope. Needs differentiability of \( f \) on a symmetric neighbourhood of the points concerned; the same argument on \( (-r, r) \) proves the local statement. The dual statement (odd differentiable \( \Rightarrow \) derivative even) follows by the identical method.
Problems
- (Routine.) Differentiate \( h(x) = \left(3x^2 + 1\right)^7 \) on \( \mathbb{R} \), citing the chain rule explicitly.
Solution
Write \( h = f \circ g \) with \( g(x) = 3x^2 + 1 \), \( f(y) = y^7 \). Both are differentiable everywhere: \( g'(x) = 6x \) (polynomial), \( f'(y) = 7y^6 \) (power rule for \( \mathbb{N} \) exponents, itself an induction on the product rule). By the chain rule, for every \( x \in \mathbb{R} \): \[ h'(x) = f'(g(x))\,g'(x) = 7\left(3x^2+1\right)^6 \cdot 6x = 42x\left(3x^2+1\right)^6. \]
- (Routine, nested twice.) Differentiate \( h(x) = \sin^2\!\left(e^{x}\right) \), and simplify the answer to a single sine.
Solution
This is a three-fold composition \( h = f_1 \circ f_2 \circ f_3 \) with \( f_3(x) = e^x \), \( f_2(u) = \sin u \), \( f_1(v) = v^2 \). Apply the chain rule twice (formally: apply T-008 to \( f_1 \circ (f_2 \circ f_3) \), then again to \( f_2 \circ f_3 \); the hypotheses hold at every point since all three functions are everywhere differentiable): \[ h'(x) = 2\sin\!\left(e^x\right)\cdot \frac{d}{dx}\sin\!\left(e^x\right) = 2\sin\!\left(e^x\right)\cos\!\left(e^x\right)\cdot e^x. \] By the double-angle identity \( 2\sin\theta\cos\theta = \sin 2\theta \): \[ h'(x) = e^x \sin\!\left(2e^x\right). \]
- (Abstract data.) Let \( f : \mathbb{R} \to \mathbb{R} \) be differentiable with \( f'(x) = \dfrac{1}{1+x^2} \) for all \( x \). Define \( h(x) = f(f(x)) \). Find \( h'(x) \) in terms of \( f \), and evaluate \( h'(0) \) given \( f(0) = 0 \).
Solution
The hypotheses of the chain rule hold at every \( a \): \( f \) is differentiable at \( a \) and at \( f(a) \). Hence \[ h'(x) = f'(f(x))\cdot f'(x) = \frac{1}{1 + f(x)^2}\cdot\frac{1}{1+x^2} = \frac{1}{\left(1+f(x)^2\right)\left(1+x^2\right)}. \] At \( x = 0 \): \( f(0) = 0 \), so \( h'(0) = \frac{1}{(1+0)(1+0)} = 1 \). (The reader may recognise \( f = \arctan \); the computation never needs this.)
- (The degenerate-increment phenomenon.) Define \( g(x) = x^2\sin(1/x) \) for \( x \ne 0 \) and \( g(0) = 0 \), and let \( f(u) = u^2 \), \( h = f \circ g \).
(a) Prove \( g'(0) = 0 \). (b) Exhibit a sequence \( x_n \to 0 \), \( x_n \ne 0 \), with \( g(x_n) = g(0) \), and explain precisely which line of the naive chain-rule "proof" this breaks. (c) Verify directly from the definition that \( h'(0) = f'(g(0))\,g'(0) \), confirming the theorem's conclusion.
Solution
(a) For \( x \ne 0 \), \( \left|\frac{g(x) - g(0)}{x - 0}\right| = \left|x\sin(1/x)\right| \le |x| \to 0 \), so by the squeeze theorem \( g'(0) = 0 \).
(b) Take \( x_n = \frac{1}{n\pi} \): then \( \sin(1/x_n) = \sin(n\pi) = 0 \), so \( g(x_n) = 0 = g(0) \), and \( x_n \to 0 \) with \( x_n \ne 0 \). The naive proof rewrites \[ \frac{h(x)-h(0)}{x-0} = \frac{f(g(x))-f(g(0))}{g(x)-g(0)}\cdot\frac{g(x)-g(0)}{x-0}, \] which is division by \( g(x_n) - g(0) = 0 \) at every \( x_n \): the first factor is undefined on a sequence converging to \( 0 \), so the limit as \( x \to 0 \) of that product expression is not even well-formed. Carathéodory's function repairs this: here \( \varphi(u) = \frac{u^2 - 0}{u - 0} = u \) for \( u \ne 0 \), extended by \( \varphi(0) = f'(0) = 0 \) — so simply \( \varphi(u) = u \) — replaces that quotient by a function defined everywhere.
(c) \( h(x) = g(x)^2 = x^4\sin^2(1/x) \) for \( x \ne 0 \), \( h(0) = 0 \). Then \( \left|\frac{h(x)-h(0)}{x}\right| = \left|x^3 \sin^2(1/x)\right| \le |x|^3 \to 0 \), so \( h'(0) = 0 \). And \( f'(g(0))\,g'(0) = f'(0)\cdot 0 = 2\cdot 0 \cdot 0 = 0 \). The two agree, as T-008 guarantees — its proof never performed the division that broke in (b).
- (Carathéodory's lemma in full.) Let \( J \subseteq \mathbb{R} \) be an open interval, \( b \in J \), \( f : J \to \mathbb{R} \). Prove: \( f \) is differentiable at \( b \) if and only if there exists \( \varphi : J \to \mathbb{R} \), continuous at \( b \), with
\[ f(y) - f(b) = \varphi(y)(y - b) \quad \text{for all } y \in J, \]
and in that case \( \varphi(b) = f'(b) \). Then explain in one paragraph why this equivalence, unlike the difference-quotient definition, survives in normed spaces of dimension greater than one.
Solution
(\(\Rightarrow\)) Suppose \( f'(b) \) exists. Define \( \varphi(y) = \frac{f(y)-f(b)}{y-b} \) for \( y \ne b \) and \( \varphi(b) = f'(b) \). The factorisation identity holds for \( y \ne b \) by construction (multiply through by \( y - b \)) and at \( y = b \) trivially (both sides \( 0 \)). Continuity at \( b \): \( \lim_{y\to b}\varphi(y) = \lim_{y \to b}\frac{f(y)-f(b)}{y-b} = f'(b) = \varphi(b) \), which is the definition of continuity at the point.
(\(\Leftarrow\)) Suppose such a \( \varphi \) exists. For \( y \ne b \), divide the identity by \( y - b \ne 0 \): \( \frac{f(y)-f(b)}{y-b} = \varphi(y) \). By continuity of \( \varphi \) at \( b \), the right side tends to \( \varphi(b) \) as \( y \to b \); hence the left side has a limit, i.e. \( f \) is differentiable at \( b \), with \( f'(b) = \varphi(b) \). (Uniqueness of \( \varphi(b) \) is forced: any two admissible \( \varphi \) agree on \( J \setminus \{b\} \) by the division just performed, hence at \( b \) by continuity. Off \( b \), \( \varphi \) is uniquely determined; only its value at \( b \) required a choice, and continuity pins it.)
Why it generalises. The difference-quotient definition requires dividing the increment \( f(y) - f(b) \) by \( y - b \), an operation with no meaning when \( y - b \) is a vector. The Carathéodory form asks instead for a factorisation of the increment through a (matrix- or operator-valued) function \( \Phi \) continuous at \( b \): \( f(y) - f(b) = \Phi(y)(y-b) \), where \( \Phi(y) \) is a linear map applied to the vector \( y - b \). No division occurs, so the formulation transfers to \( \mathbb{R}^n \) and to normed spaces, where it is equivalent to Fréchet differentiability (with \( \Phi(b) = Df(b) \)); the chain-rule proof given on this page then goes through verbatim with products of numbers replaced by compositions of linear maps. One caveat worth knowing: in dimension \( \gt 1 \) the factor \( \Phi \) is no longer unique off the point \( b \) — many matrices send a given nonzero vector to a given vector — so \( \Phi \) is a witness, not a canonical object.