The Chain Rule and Computational Graphs
The chain rule computes the derivative of a composition of functions by multiplying the derivatives of the constituent functions. In words: to differentiate , multiply the rate of change of (at ) by the rate of change of (at ). It applies everywhere derivatives appear — single-variable calculus, multivariable analysis, differential geometry, and modern machine learning (where its computational-graph form is called backpropagation). First systematized by Leibniz (1676) via differential notation; the computational-graph perspective matured with reverse-mode automatic differentiation in the 1970s–80s.
A composition is a pipeline: . The chain rule says the overall sensitivity is the product of local sensitivities along the pipeline. On a graph with branches and merges, "product along a path" generalizes to "sum over all paths, each path being a product of edge derivatives." Reverse-mode differentiation is just an efficient order of summation that reuses shared subexpressions.
Formal Statement
Given functions and with , the composite is defined by . We call the inner function and the outer function. The intermediate value is the node variable connecting them.
Let be differentiable at and let be differentiable at . Then is differentiable at and
Derivation hint: Differentiate at the point , then multiply by the inner rate ; see the proof below using the error-form of differentiability. In Leibniz notation, with , :
Derivation hint: Treat and as ratios of differentials; the cancellation of is suggestive but must be justified by the limit argument in the proof.
Let be differentiable at and differentiable at . Then the Jacobian of the composite is the matrix product of the Jacobians:
Derivation hint: Apply the linear-approximation definition of total differentiability to both maps; the composite's best linear approximation is the composition of the linear approximations, whose matrix is the product. Componentwise, for a scalar where each :
Derivation hint: Expand the matrix product in for a single output row and single input column; the sum runs over the shared intermediate variables — this is the "sum over paths through the layer."
A computational graph for an expression is a directed acyclic graph where each vertex holds a variable computed by an elementary operation of its parent vertices : . Source vertices are inputs; a designated sink is the output. Each edge carries the local partial derivative , evaluated at the current values. The full derivative of the output with respect to an input is obtained by applying the chain rule across the graph.
Why It Holds / Derivation
proof[Single-Variable Chain Rule via the Error Form] Step 1 — Differentiability as linear approximation with controlled error. Because is differentiable at , there is a function with such that for all small :
Derivation hint: Define for and ; differentiability forces .
Step 2 — Set the inner increment. Let be a small increment in , and define . By differentiability of , as .
Step 3 — Substitute. Then
Derivation hint: Replace by in ; this remains valid even when because the right side then vanishes too.
Step 4 — Divide by and take the limit.
Derivation hint: As : (since ), and the difference quotient of tends to ; multiply the limits. Taking gives .
The seductive argument followed by taking limits breaks when for some sequence of (e.g. locally constant or oscillating). Division by is then illegal. The error-form proof above avoids any division by , which is exactly why it is the correct argument.
Leibniz, co-inventor of calculus, gave us the differential notation in which the chain rule appears as the almost-tautological cancellation . His manuscripts from November 1676 already manipulate composite differentials. While the notation makes the rule memorable, it obscures the subtlety (see the warning above) — a gap rigorously closed only with the 19th-century – definition of the limit by Cauchy and Weierstrass. Leibniz's deeper gift was the operational viewpoint: differentiation as a symbolic process that propagates along the structure of an expression — the conceptual seed of computational graphs three centuries later.
Building Intuition
Think of nested gears. If gear drives gear at ratio (B turns 3× as fast), and drives at ratio , then drives at — ratios multiply. The derivative is the local gear ratio from to ; is the ratio from to ; the composite ratio is their product. Now add branching. If influences through two independent gear trains (paths), the total effect is the sum of the two products — small pushes from each route add up. That is exactly : sum over paths, multiply along each. The computational graph is the literal gear diagram, and backpropagation is the disciplined way to total up all the ratios without recomputing shared gears.
Worked Examples
Given: . Find at .
Step 1 — Identify the layers. Outer: . Middle: . Inner: . Three nested functions.
Step 2 — Local derivatives.
Step 3 — Multiply (chain rule for a 3-chain).
Derivation hint: Apply twice: ; substitute , .
Step 4 — Evaluate at . Here , so , .
The zero makes sense: at , is at its maximum, so momentarily stops changing.
Given: at . Compute and by a forward pass then a backward pass.
Forward pass (compute node values).
Backward pass (seed , propagate adjoints).
Derivation hint: Each adjoint ; multiply the downstream adjoint by the local edge derivative.
Accumulate to inputs (sum over all incoming paths).
Derivation hint: reaches by two paths — through and directly via the term; tells us to add them.
Derivation hint: reaches only through ; one path, so a single product.
Note: a single backward pass produced both partials — the efficiency that powers backpropagation.
Common Misconceptions
1. Evaluating the outer derivative at instead of at . must be evaluated at , not . Writing is wrong; it is . 2. Forgetting the inner derivative entirely. . The factor is mandatory. 3. Treating as a genuine fraction. It is notation for a limit. The cancellation works as a mnemonic but is not a proof, and it fails to generalize cleanly to partial derivatives, where in general.
Let for , . Then is differentiable at with , but oscillates wildly near and equals infinitely often as . With (so ), the naïve "divide by " proof is invalid on those sequences — yet the chain rule still holds because the error-form proof (–) never divides by . This is the canonical example showing why rigor matters.
Connections
The chain rule is the connective tissue of differential calculus. It powers Implicit Differentiation (differentiate and solve for ), Related Rates (link to through ), and The Substitution Rule for Integration (which is the chain rule read backwards). In several variables it underlies the Gradient and Directional Derivative and the Jacobian Matrix. Its graph form is precisely Backpropagation in neural networks, and the abstract version — composition of linear approximations — is the statement of the Total Derivative in Differential Geometry (the functoriality of the tangent map: ).
Real-World Applications
Historical Development
Subtleties & Limits
The chain rule requires differentiability; at points where the inner or outer function is merely continuous (e.g. at ), the composite may fail to be differentiable or require subgradients — leading to the calculus of Clarke subdifferentials and questions about which "nonsmooth chain rules" hold for compositions like networks, where backpropagation is used in practice despite kink points. A related modern theme is numerical stability: repeated multiplication of edge derivatives causes vanishing or exploding gradients in deep graphs; understanding when the product of many Jacobians stays well-conditioned (via residual connections, normalization, orthogonal initialization) remains an active research area. Finally, in infinite-dimensional and stochastic settings, generalizations (Fréchet-derivative chain rule, Itô's formula as a "stochastic chain rule" with an extra second-order term) show that the simple product law is only the smooth, deterministic special case of a richer family of composition rules.
See Also
Product Rule · Quotient Rule · Jacobian Matrix · Gradient and Directional Derivative · Backpropagation · Automatic Differentiation · Faà di Bruno's Formula · Itô's Lemma · Total Derivative