The Chain Rule in Multiple Variables

⚡ Key Takeaways

One-line statement: The multivariable chain rule computes the derivative of a composition of functions by summing the contributions of all intermediate variables through which one variable depends on another.

Key result in words: If zz depends on several intermediate variables, and each of those depends on the true independent variables, the total rate of change of zz with respect to an independent variable is the sum over every intermediate path of (rate of zz w.r.t. that intermediate) × (rate of that intermediate w.r.t. the independent variable).

Where it applies: Differential calculus of functions Rn→Rm\mathbb{R}^n \to \mathbb{R}^m, implicit differentiation, change of variables, PDEs, optimization (gradient descent / backpropagation), thermodynamics, differential geometry.

Who/when: Roots in Leibniz (1670s) and Euler (1734); the modern total-derivative formulation matured with Cauchy and Jacobi in the 19th century.

💡 The Core Insight

A differentiable function is, locally, its best linear approximation — encoded by the Jacobian matrix. Composition of functions corresponds to composition of their linear approximations, and composition of linear maps is matrix multiplication. Therefore:

D(f∘g)=(Df) (Dg).D(\mathbf f \circ \mathbf g) = (D\mathbf f)\,(D\mathbf g).

Every "sum over paths" version of the chain rule you ever write down is just one entry of this matrix product spelled out.

Formal Statement

DefinitionPartial Derivative and Jacobian

For f:Rn→Rm\mathbf{f}:\mathbb{R}^n\to\mathbb{R}^m, f=(f1,…,fm)\mathbf{f}=(f_1,\dots,f_m), the partial derivative of component fif_i with respect to coordinate xjx_j is

1
∂fi∂xj(a)=lim⁡h→0fi(a+hej)−fi(a)h,\quad \frac{\partial f_i}{\partial x_j}(\mathbf a)=\lim_{h\to 0}\frac{f_i(\mathbf a+h\mathbf e_j)-f_i(\mathbf a)}{h},

Derivation hint: hold all coordinates but xjx_j fixed; this is an ordinary one-variable difference quotient along the jj-th axis. The Jacobian matrix Df(a)∈Rm×nD\mathbf f(\mathbf a)\in\mathbb{R}^{m\times n} collects these:

2
(Df(a))ij=∂fi∂xj(a),Df=(∇f1⋮∇fm).\quad \big(D\mathbf f(\mathbf a)\big)_{ij}=\frac{\partial f_i}{\partial x_j}(\mathbf a),\qquad D\mathbf f=\begin{pmatrix}\nabla f_1\\ \vdots\\ \nabla f_m\end{pmatrix}.

Derivation hint: stack the gradients (row vectors) of each component function; row ii, column jj is ∂fi/∂xj\partial f_i/\partial x_j. Here ej\mathbf e_j is the jj-th standard basis vector and ∇fi=(∂fi/∂x1,…,∂fi/∂xn)\nabla f_i=(\partial f_i/\partial x_1,\dots,\partial f_i/\partial x_n).

DefinitionDifferentiability (Total Derivative)

f:Rn→Rm\mathbf f:\mathbb{R}^n\to\mathbb{R}^m is differentiable at a\mathbf a if there is a linear map L=Df(a)L=D\mathbf f(\mathbf a) with

3
lim⁡h→0∥f(a+h)−f(a)−Lh∥∥h∥=0.\quad \lim_{\mathbf h\to\mathbf 0}\frac{\big\|\mathbf f(\mathbf a+\mathbf h)-\mathbf f(\mathbf a)-L\mathbf h\big\|}{\|\mathbf h\|}=0.

Derivation hint: demand that the linear part LhL\mathbf h captures the change up to an error that vanishes faster than ∥h∥\|\mathbf h\| — this is the genuine, basis-free notion of derivative.

TheoremMultivariable Chain Rule

Let g:Rp→Rn\mathbf g:\mathbb{R}^p\to\mathbb{R}^n be differentiable at t∈Rp\mathbf t\in\mathbb{R}^p and f:Rn→Rm\mathbf f:\mathbb{R}^n\to\mathbb{R}^m differentiable at x=g(t)\mathbf x=\mathbf g(\mathbf t). Then f∘g\mathbf f\circ\mathbf g is differentiable at t\mathbf t and

4
D(f∘g)(t)=Df(g(t))⋅Dg(t).\quad D(\mathbf f\circ\mathbf g)(\mathbf t)=D\mathbf f\big(\mathbf g(\mathbf t)\big)\cdot D\mathbf g(\mathbf t).

Derivation hint: the best linear approximation of a composite is the composite of the best linear approximations; in matrix form composition = product. In coordinates, with z=fz=f a scalar depending on x1,…,xnx_1,\dots,x_n and each xk=xk(t1,…,tp)x_k=x_k(t_1,\dots,t_p):

5
∂z∂tj=∑k=1n∂z∂xk ∂xk∂tj.\quad \frac{\partial z}{\partial t_j}=\sum_{k=1}^{n}\frac{\partial z}{\partial x_k}\,\frac{\partial x_k}{\partial t_j}.

Derivation hint: equation [5] is exactly the (1,j)(1,j) entry of the matrix product [4]; the sum over kk runs over the intermediate variables (the inner dimension of the product). The special case p=1p=1 (a single parameter tt, a curve x(t)\mathbf x(t)) gives the total derivative along a path:

6
dzdt=∑k=1n∂z∂xk dxkdt=∇z⋅dxdt.\quad \frac{dz}{dt}=\sum_{k=1}^{n}\frac{\partial z}{\partial x_k}\,\frac{dx_k}{dt}=\nabla z\cdot \frac{d\mathbf x}{dt}.

Derivation hint: set p=1p=1 in [5]; the row vector ∇z\nabla z dotted with the velocity vector dx/dtd\mathbf x/dt is the directional rate of change along the curve.

Why It Holds / Derivation

ProofTotal-Derivative Chain Rule

We prove [4]. Write x=g(t)\mathbf x=\mathbf g(\mathbf t), A=Df(x)A=D\mathbf f(\mathbf x), B=Dg(t)B=D\mathbf g(\mathbf t).

Step 1 — Set up linear approximations. By differentiability of g\mathbf g at t\mathbf t,

7
g(t+h)=g(t)+Bh+r(h),∥r(h)∥∥h∥→0.\quad \mathbf g(\mathbf t+\mathbf h)=\mathbf g(\mathbf t)+B\mathbf h+\mathbf r(\mathbf h),\qquad \frac{\|\mathbf r(\mathbf h)\|}{\|\mathbf h\|}\to 0.

Derivation hint: this is definition [3] applied to g\mathbf g, with remainder r\mathbf r.

Step 2 — Feed into f\mathbf f. Let k=g(t+h)−x=Bh+r(h)\mathbf k=\mathbf g(\mathbf t+\mathbf h)-\mathbf x=B\mathbf h+\mathbf r(\mathbf h). By differentiability of f\mathbf f at x\mathbf x,

8
f(x+k)=f(x)+Ak+s(k),∥s(k)∥∥k∥→0.\quad \mathbf f(\mathbf x+\mathbf k)=\mathbf f(\mathbf x)+A\mathbf k+\mathbf s(\mathbf k),\qquad \frac{\|\mathbf s(\mathbf k)\|}{\|\mathbf k\|}\to 0.

Derivation hint: same definition [3] applied to f\mathbf f, with remainder s\mathbf s.

Step 3 — Combine. Substitute k\mathbf k:

9
(f∘g)(t+h)−(f∘g)(t)=ABh+A r(h)+s(k)⏟= ρ(h).\quad (\mathbf f\circ\mathbf g)(\mathbf t+\mathbf h)-(\mathbf f\circ\mathbf g)(\mathbf t)=AB\mathbf h+\underbrace{A\,\mathbf r(\mathbf h)+\mathbf s(\mathbf k)}_{=\ \boldsymbol\rho(\mathbf h)}.

Derivation hint: Ak=A(Bh+r)=ABh+ArA\mathbf k = A(B\mathbf h+\mathbf r)=AB\mathbf h+A\mathbf r; group all non-linear leftovers into ρ\boldsymbol\rho.

Step 4 — Error estimate. We must show ∥ρ(h)∥/∥h∥→0\|\boldsymbol\rho(\mathbf h)\|/\|\mathbf h\|\to 0.

  • ∥A r(h)∥≤∥A∥op ∥r(h)∥=o(∥h∥)\|A\,\mathbf r(\mathbf h)\|\le\|A\|_{\mathrm{op}}\,\|\mathbf r(\mathbf h)\|=o(\|\mathbf h\|) by Step 1.
  • For s(k)\mathbf s(\mathbf k): ∥k∥≤(∥B∥op+1)∥h∥\|\mathbf k\|\le(\|B\|_{\mathrm{op}}+1)\|\mathbf h\| for small h\mathbf h, and ∥s(k)∥=o(∥k∥)=o(∥h∥)\|\mathbf s(\mathbf k)\|=o(\|\mathbf k\|)=o(\|\mathbf h\|).
10
∥ρ(h)∥∥h∥≤∥A∥op∥r∥∥h∥+∥s(k)∥∥k∥⋅∥k∥∥h∥ ⟶ 0.\quad \frac{\|\boldsymbol\rho(\mathbf h)\|}{\|\mathbf h\|}\le \|A\|_{\mathrm{op}}\frac{\|\mathbf r\|}{\|\mathbf h\|}+\frac{\|\mathbf s(\mathbf k)\|}{\|\mathbf k\|}\cdot\frac{\|\mathbf k\|}{\|\mathbf h\|}\ \longrightarrow\ 0.

Derivation hint: bound each term using operator-norm linearity and the two o(⋅)o(\cdot) conditions; the product of a vanishing factor and a bounded factor vanishes.

Conclusion. Equation [9] exhibits ABAB as a linear map satisfying definition [3] for f∘g\mathbf f\circ\mathbf g. By uniqueness of the total derivative, D(f∘g)(t)=ABD(\mathbf f\circ\mathbf g)(\mathbf t)=AB. ■\blacksquare (A subtle point: mere existence of partial derivatives is not enough; the proof crucially uses full differentiability of both maps — see the Counterexample below.)

∎
LE
Leonhard Euler
1707–1783

Euler, in his Institutiones calculi differentialis and earlier papers (notably from 1734 onward), was among the first to systematically manipulate functions of several variables and the relations among their partial differentials. The notation and the practice of summing partial-differential contributions — the seed of equation [5] — grow directly from Euler's treatment of "functions of functions." His introduction of the symbol for partial differentiation and his fearless symbolic computation made the multivariable chain rule a routine tool a full century before its rigorous ϵ\epsilon–δ\delta foundation.

Building Intuition

🧠 Intuition

Think of zz as the elevation on a mountain and imagine you are hiking along a trail parameterized by time tt, so your position is x(t)=(x(t),y(t))\mathbf x(t)=(x(t),y(t)). Two things determine how fast your altitude changes: 1. How steep the mountain is in the east and north directions — the partials ∂z/∂x\partial z/\partial x, ∂z/∂y\partial z/\partial y. 2. How fast you are moving east and north — the velocities dx/dtdx/dt, dy/dtdy/dt. Your altitude rate dz/dtdz/dt is the steepness in your direction of travel, obtained by weighting each slope by the corresponding speed and adding them (equation [6]). This is precisely ∇z⋅v\nabla z\cdot \mathbf v. The "tree diagram" / sum-over-paths picture: draw zz at the top, its intermediate variables xkx_k below, and the true variables tjt_j at the bottom. Every directed path from zz down to tjt_j contributes a product of the derivatives along its edges; the chain rule says sum over all paths. The inner summation index kk in [5] is literally "which intermediate node did you pass through."

Figure
Tree diagram for z=f(x,y)z=f(x,y), x=x(s,t)x=x(s,t), y=y(s,t)y=y(s,t). Each path from zz to tt contributes a product; sum the paths.
z x y s t t s ∂z/∂x ∂z/∂y ∂x/∂s ∂x/∂t ∂y/∂s ∂y/∂t ∂z/∂t = (∂z/∂x)(∂x/∂t) + (∂z/∂y)(∂y/∂t)

Worked Examples

ExampleAltitude rate along a circular path

Given: z=f(x,y)=x2yz=f(x,y)=x^2 y (units: meters, with x,yx,y in meters). A particle moves along x(t)=cos⁡tx(t)=\cos t, y(t)=sin⁡ty(t)=\sin t (meters), with tt in seconds. Find dz/dtdz/dt at t=π/4t=\pi/4.

Step 1 — Partials. ∂z∂x=2xy,∂z∂y=x2.\displaystyle\frac{\partial z}{\partial x}=2xy,\qquad \frac{\partial z}{\partial y}=x^2.

Step 2 — Velocities. dxdt=−sin⁡t,dydt=cos⁡t.\displaystyle\frac{dx}{dt}=-\sin t,\qquad \frac{dy}{dt}=\cos t.

Step 3 — Apply [6].

dzdt=2xy(−sin⁡t)+x2(cos⁡t).\frac{dz}{dt}=2xy(-\sin t)+x^2(\cos t).

Step 4 — Evaluate at t=π/4t=\pi/4: x=y=22x=y=\tfrac{\sqrt2}{2}, sin⁡t=cos⁡t=22\sin t=\cos t=\tfrac{\sqrt2}{2}.

2⋅12⋅(−22)+12⋅22=−22+24=−24.2\cdot\tfrac12\cdot\Big(-\tfrac{\sqrt2}{2}\Big)+\tfrac12\cdot\tfrac{\sqrt2}{2} =-\tfrac{\sqrt2}{2}+\tfrac{\sqrt2}{4}=-\tfrac{\sqrt2}{4}.
 dzdt∣t=π/4=−24≈−0.354 m/s \boxed{\ \dfrac{dz}{dt}\Big|_{t=\pi/4}=-\dfrac{\sqrt2}{4}\approx-0.354\ \text{m/s}\ }

Check: Substituting first, z=cos⁡2t sin⁡tz=\cos^2 t\,\sin t, z′=−2cos⁡tsin⁡2t+cos⁡3tz'=-2\cos t\sin^2 t+\cos^3 t; at π/4\pi/4 this is −2(22)(12)+(22)3=−22+24=−24.-2(\tfrac{\sqrt2}{2})(\tfrac12)+(\tfrac{\sqrt2}{2})^3=-\tfrac{\sqrt2}{2}+\tfrac{\sqrt2}{4}=-\tfrac{\sqrt2}{4}. ✓

ExamplePolar change of variables — a Jacobian product

Given: w=f(x,y)w=f(x,y) with x=rcos⁡θx=r\cos\theta, y=rsin⁡θy=r\sin\theta. Express ∂w/∂r\partial w/\partial r and ∂w/∂θ\partial w/\partial\theta via ∂w/∂x, ∂w/∂y\partial w/\partial x,\ \partial w/\partial y, then evaluate for f=x2+y2f=x^2+y^2 at (r,θ)=(2,π/3)(r,\theta)=(2,\pi/3).

Step 1 — Jacobian of (x,y)(x,y) w.r.t. (r,θ)(r,\theta).

Dg=(∂x/∂r∂x/∂θ∂y/∂r∂y/∂θ)=(cos⁡θ−rsin⁡θsin⁡θrcos⁡θ).D\mathbf g=\begin{pmatrix}\partial x/\partial r & \partial x/\partial\theta\\[2pt]\partial y/\partial r & \partial y/\partial\theta\end{pmatrix}=\begin{pmatrix}\cos\theta & -r\sin\theta\\ \sin\theta & r\cos\theta\end{pmatrix}.

Step 2 — Chain rule [5] (row-vector form).

(∂w∂r, ∂w∂θ)=(∂w∂x, ∂w∂y)Dg.\Big(\frac{\partial w}{\partial r},\ \frac{\partial w}{\partial\theta}\Big) =\Big(\frac{\partial w}{\partial x},\ \frac{\partial w}{\partial y}\Big)D\mathbf g.

So

∂w∂r=wxcos⁡θ+wysin⁡θ,∂w∂θ=−wx rsin⁡θ+wy rcos⁡θ.\frac{\partial w}{\partial r}=w_x\cos\theta+w_y\sin\theta,\qquad \frac{\partial w}{\partial\theta}=-w_x\,r\sin\theta+w_y\,r\cos\theta.

Step 3 — Plug in f=x2+y2f=x^2+y^2: wx=2x=2rcos⁡θw_x=2x=2r\cos\theta, wy=2y=2rsin⁡θw_y=2y=2r\sin\theta.

∂w∂r=2rcos⁡2θ+2rsin⁡2θ=2r,∂w∂θ=−2r2cos⁡θsin⁡θ+2r2sin⁡θcos⁡θ=0.\frac{\partial w}{\partial r}=2r\cos^2\theta+2r\sin^2\theta=2r,\qquad \frac{\partial w}{\partial\theta}=-2r^2\cos\theta\sin\theta+2r^2\sin\theta\cos\theta=0.

Step 4 — Evaluate at (2,π/3)(2,\pi/3).

 ∂w∂r=2r=4,∂w∂θ=0 \boxed{\ \frac{\partial w}{\partial r}=2r=4,\qquad \frac{\partial w}{\partial\theta}=0\ }

Sanity check: In polar coordinates w=x2+y2=r2w=x^2+y^2=r^2, so ∂w/∂r=2r=4\partial w/\partial r=2r=4 and ∂w/∂θ=0\partial w/\partial\theta=0 exactly — consistent, since ww is rotationally symmetric. ✓

Common Misconceptions

⚠️ The treacherous "cancellation" of partials

The single-variable mnemonic "dzdt=dzdxdxdt\frac{dz}{dt}=\frac{dz}{dx}\frac{dx}{dt}, cancel the dxdx" does not survive intact. With multiple intermediate variables you must sum over all of them; dropping a path is the most common error:

∂z∂t ≠ ∂z∂x∂x∂t(missing the y path).\frac{\partial z}{\partial t}\ \neq\ \frac{\partial z}{\partial x}\frac{\partial x}{\partial t}\quad\text{(missing the }y\text{ path).}

Also, ∂z/∂x\partial z/\partial x inside the chain rule is evaluated at the image point g(t)\mathbf g(\mathbf t), not at t\mathbf t. And the symbols ∂z/∂t\partial z/\partial t on the left vs. the partial of the original zz "w.r.t. tt" can mean genuinely different things when tt appears both directly and through intermediate variables — always specify what is held constant. In thermodynamics this ambiguity is so severe that the held-constant variable is written as a subscript, e.g. (∂U/∂T)V\left(\partial U/\partial T\right)_V.

CounterexamplePartials exist but the chain rule fails — because differentiability fails

Existence of partial derivatives does not imply the chain rule. Let

f(x,y)={xyx2+y2,(x,y)≠(0,0)0,(x,y)=(0,0).f(x,y)=\begin{cases}\dfrac{xy}{x^2+y^2}, & (x,y)\neq(0,0)\\[6pt] 0, & (x,y)=(0,0).\end{cases}

Both partials exist at the origin: fx(0,0)=fy(0,0)=0f_x(0,0)=f_y(0,0)=0 (since f≡0f\equiv0 on the axes). Now compose with the line x(t)=t, y(t)=tx(t)=t,\ y(t)=t. Along it f(t,t)=t22t2=12f(t,t)=\frac{t^2}{2t^2}=\frac12 for t≠0t\neq0 and f(0,0)=0f(0,0)=0, so g(t)=f(x(t),y(t))g(t)=f(x(t),y(t)) is discontinuous at t=0t=0 and g′(0)g'(0) does not exist. The naive chain-rule prediction fx x′+fy y′=0⋅1+0⋅1=0f_x\,x' + f_y\,y' = 0\cdot1+0\cdot1=0 is meaningless. The fix: the theorem requires ff to be differentiable (e.g. C1C^1) at the point, which this ff is not — it is not even continuous at the origin along y=xy=x.

Connections

connection

The chain rule is the connective tissue between many areas:

  • <span class="wiki-link-missing">Gradient and Directional Derivative</span> — equation [6], dz/dt=∇z⋅vdz/dt=\nabla z\cdot\mathbf v, is the directional derivative; the chain rule along a curve recovers it.
  • <span class="wiki-link-missing">Jacobian Matrix and Determinant</span> — the rule says Jacobians multiply, D(f∘g)=Df DgD(\mathbf f\circ\mathbf g)=D\mathbf f\,D\mathbf g, hence Jacobian determinants multiply, the engine of Change of Variables in Multiple Integrals.
  • <span class="wiki-link-missing">Implicit Function Theorem</span> — differentiating a constraint F(x,y)=0F(x,y)=0 via the chain rule yields dy/dx=−Fx/Fydy/dx=-F_x/F_y.
  • <span class="wiki-link-missing">Inverse Function Theorem</span> — applying the rule to f−1∘f=id\mathbf f^{-1}\circ\mathbf f=\mathrm{id} gives D(f−1)=(Df)−1D(\mathbf f^{-1})=(D\mathbf f)^{-1}.
  • <a class="wiki-link" href="/wiki/cs-dl-backpropagation">Backpropagation</a> — reverse-mode automatic differentiation is the chain rule [4] computed right-to-left across a composition of layers.
  • <span class="wiki-link-missing">Total Differential</span> — dz=∑k(∂z/∂xk) dxkdz=\sum_k (\partial z/\partial x_k)\,dx_k is the chain rule in differential-form clothing.

Real-World Applications

🔬 Where this appears

Historical Development

⏳ History
- 1670s — Leibniz develops differential notation dx,dydx, dy and manipulates differentials of composite quantities, implicitly using a chain-rule idea via "infinitesimal" substitution.
- 1734 — Euler studies functions of two variables and the relations among their partial differentials, foreshadowing the summed form [5].
- 1755 — Euler's Institutiones calculi differentialis systematizes differentiation, including composite functions of several variables.
- 1797 — Lagrange (Théorie des fonctions analytiques) promotes the functional/derivative viewpoint, refining the notation f′f'.
- 1821 — Cauchy (Cours d'analyse) introduces rigorous limits, giving the single-variable chain rule its first sound proof and paving the way for the multivariable case.
- 1841 — Carl Jacobi introduces the functional determinant (the Jacobian), making the matrix structure of multivariable derivatives explicit and central to change of variables.
- 1860s–1880s — Riemann, Beltrami, Christoffel employ chain-rule transformation laws as the foundation of differential geometry and tensor analysis.
- 1900s — Fréchet and Gâteaux generalize the derivative to normed/infinite-dimensional spaces, where the chain rule D(f∘g)=Df∘DgD(f\circ g)=Df\circ Dg takes its definitive operator form.
- 1986 — Rumelhart, Hinton & Williams popularize backpropagation, the chain rule's most consequential 20th-century application, igniting modern deep learning.

Subtleties & Limits

open-problem

The classical theorem is closed and complete, but several boundary issues reward attention:

  • Differentiability vs. partial derivatives. As the counterexample shows, C1C^1 (or full Fréchet differentiability) is essentially needed; partials alone can fail. Characterizing the minimal regularity under which a chain-rule identity holds in measure-theoretic or Sobolev settings (the chain rule for Sobolev/BV functions, the Vol'pert chain rule) remains a delicate research area in geometric measure theory.
  • Nonsmooth analysis. For convex or merely locally Lipschitz functions, one replaces ∇f\nabla f with the subdifferential or Clarke generalized gradient; the chain rule becomes an inclusion ∂(f∘g)⊆\partial(f\circ g)\subseteq (a set), with equality only under qualification conditions.
  • Infinite dimensions. In Banach spaces the Fréchet chain rule holds, but for the weaker Gâteaux derivative the chain rule can fail unless additional continuity is assumed — a genuine subtlety in the calculus of variations and PDE.
  • Automatic differentiation accuracy. Reverse-mode AD is exact in exact arithmetic, but the practical question of numerically stable, memory-efficient chain-rule evaluation for very deep or recurrent compositions (checkpointing, vanishing/exploding gradients) is an active engineering frontier.

See Also

Gradient and Directional Derivative · Total Differential · Inverse Function Theorem · Material Derivative · Tensor Transformation Laws · Automatic Differentiation