Deriving it from the total differential
The cleanest derivation reuses the
total differential.
Step 1 — start from the total differential. A small change in
z = f(x, y) from small changes in its inputs is, to first order,
dz = \frac{\partial f}{\partial x}\, dx + \frac{\partial f}{\partial y}\, dy.
Step 2 — divide through by dt. Both
x and y change only because
t does, so divide the whole relation by the time increment:
\frac{dz}{dt} = \frac{\partial f}{\partial x}\,\frac{dx}{dt} + \frac{\partial f}{\partial y}\,\frac{dy}{dt}.
That is the rule — a single line, falling straight out of the linear approximation. Now three
worked examples, moving from a pure check, to two inputs at once, to real numbers on the
dashboard.
Worked example 1 — checking the rule against direct substitution
Let z = f(x, y) = x^2 y with
x = \cos t and y = \sin t. Find
dz/dt two ways and confirm they agree.
Method A — the chain rule. The partials of f are
\partial f/\partial x = 2xy and
\partial f/\partial y = x^2; the input speeds are
dx/dt = -\sin t and dy/dt = \cos t.
Assemble:
\frac{dz}{dt} = 2xy(-\sin t) + x^2(\cos t) = 2\cos t \sin t\,(-\sin t) + \cos^2 t \, (\cos t) = -2\sin^2 t \cos t + \cos^3 t.
Method B — substitute first, then differentiate directly. Write
z(t) = \cos^2 t \sin t outright and use the product rule on
\cos^2 t and \sin t:
\frac{dz}{dt} = \underbrace{2\cos t(-\sin t)}_{\text{derivative of }\cos^2 t} \cdot \sin t + \cos^2 t \cdot \cos t = -2\sin^2 t \cos t + \cos^3 t.
Same answer, both ways — exactly
-2\sin^2t\cos t + \cos^3 t = \cos t\,(3\cos^2 t - 2) after factoring.
The chain rule is not a shortcut that risks a different result; it is a bookkeeping device for
doing the substitute-then-differentiate calculation without ever writing out the messy
substituted formula.
Worked example 2 — two parameters at once
Now let z = f(x, y) = x^2 y with two independent
parameters feeding x and y:
x = s + 2t and y = 2s - t. Find
\partial z/\partial s and
\partial z/\partial t at s = 1,
t = 1.
Step 1 — the partials of f (same as before):
f_x = 2xy, f_y = x^2.
Step 2 — the partials of the inputs with respect to each parameter:
\frac{\partial x}{\partial s} = 1, \quad \frac{\partial x}{\partial t} = 2, \qquad \frac{\partial y}{\partial s} = 2, \quad \frac{\partial y}{\partial t} = -1.
Step 3 — assemble, one sum per parameter (each sum only follows the branches
that reach that parameter):
\frac{\partial z}{\partial s} = f_x\frac{\partial x}{\partial s} + f_y\frac{\partial y}{\partial s} = 2xy(1) + x^2(2), \qquad \frac{\partial z}{\partial t} = f_x\frac{\partial x}{\partial t} + f_y\frac{\partial y}{\partial t} = 2xy(2) + x^2(-1).
Step 4 — plug in numbers. At s = 1, t = 1:
x = 1 + 2(1) = 3 and y = 2(1) - 1 = 1. So
\frac{\partial z}{\partial s} = 2(3)(1) + (3)^2(2) = 6 + 18 = 24, \qquad \frac{\partial z}{\partial t} = 2(3)(1)(2) + (3)^2(-1) = 12 - 9 = 3.
Two different sums from the same two partials of f — one
weighted by the s-branches, one by the
t-branches. That reuse is exactly what the tree diagram below makes
visual.
Worked example 3 — back to the dashboard, with real numbers
A car's position at time t (in hours) is
x(t) = 3t, y(t) = 4t (driving
north-east at a steady pace), and the temperature map is
T(x, y) = 100 - x^2 - y^2 (degrees, cooling away from the origin).
Find how fast the dashboard reading is changing at t = 1.
Step 1 — partials of the field:
T_x = -2x, T_y = -2y.
Step 2 — the car's speeds: dx/dt = 3,
dy/dt = 4 (constant — the car moves at a steady velocity).
Step 3 — assemble:
\frac{dT}{dt} = T_x\frac{dx}{dt} + T_y\frac{dy}{dt} = (-2x)(3) + (-2y)(4) = -6x - 8y.
Step 4 — evaluate at t = 1, where
x = 3, y = 4:
\frac{dT}{dt}\bigg|_{t=1} = -6(3) - 8(4) = -18 - 32 = -50 \text{ degrees per hour.}
The dashboard is dropping at 50 degrees per hour at that instant —
not because the weather is changing, but purely because the car is driving into colder territory
faster than it can drive into warmer territory. Drag t below to send
a dot around a path on a (simpler) contour map and watch z(t) respond
live.
The gradient view: one dot product instead of two terms
Collect the two partials of f into the
gradient
vector \nabla f = (f_x, f_y), and collect the input speeds into the
velocity vector \mathbf{r}'(t) = (x'(t), y'(t)). The two-term sum in
the chain rule is then nothing but a dot product:
\frac{dz}{dt} = f_x\,\frac{dx}{dt} + f_y\,\frac{dy}{dt} = \nabla f \cdot \mathbf{r}'(t).
This is more than a notational trick — the dot product form says the felt rate of change is
the gradient (the direction and steepness of fastest increase) projected onto however
you happen to be moving. Drive straight along \nabla f and you feel
the fastest possible change; drive perpendicular to it — along a level curve, as in the contour
map above — and the dot product vanishes, exactly matching
dz/dt = 0 there.
-
One parameter. If z = f(x, y) with
x = x(t), y = y(t) differentiable,
then
\frac{dz}{dt} = f_x\,\frac{dx}{dt} + f_y\,\frac{dy}{dt} = \nabla f \cdot \mathbf{r}'(t).
-
Several parameters. If instead
x = x(s, t) and y = y(s, t), the same
"sum over every road" gives a partial in each parameter:
\frac{\partial z}{\partial s} = f_x\,\frac{\partial x}{\partial s} + f_y\,\frac{\partial y}{\partial s}, \qquad \frac{\partial z}{\partial t} = f_x\,\frac{\partial x}{\partial t} + f_y\,\frac{\partial y}{\partial t}.
-
The tree diagram. Draw z branching to its
intermediate variables, each branching to the independent variable. To differentiate
z by a bottom variable, multiply along each path
from z down to it and add the paths — the
mechanical version of the formula for any number of variables.
The single most common slip is to walk the tree diagram and simply forget a
branch — especially once f depends on three or more
intermediate variables, or once a variable feeds in through more than one route.
-
If z = f(x, y, w) with x, y, w all
functions of t, the chain rule needs three
terms, one per branch:
dz/dt = f_x x' + f_y y' + f_w w'. Summing only two — because the
third variable was easy to overlook — silently drops a real contribution to the rate of
change; the result is not "approximately right", it is simply the wrong derivative.
-
Keep the discipline of \partial vs
d straight, too. If
z = f(x, t) and, separately, x = x(t),
then the partial \partial z/\partial t (treat
x as fixed, differentiate the explicit
t only) is generally not the same number as the
total dz/dt (which must also add the indirect
contribution flowing through x(t)):
\frac{dz}{dt} = \frac{\partial f}{\partial x}\frac{dx}{dt} + \frac{\partial f}{\partial t}.
Writing d when you mean the narrower, direct-only
\partial (or vice versa) is a genuinely different claim, not a
stylistic choice.
-
A quick safety check: count the branches leading into your target variable
before writing a single term, then make sure your final sum has exactly
that many terms — no more, no fewer.
The chain rule quietly explains where the implicit-differentiation formula comes from.
Suppose a curve is defined implicitly by F(x, y) = 0 — for
instance the circle F = x^2 + y^2 - 1 = 0 — and we want
dy/dx along it. Think of y as a
function of x and differentiate the equation
F(x, y(x)) = 0 with respect to x, using
the chain rule on the left:
\frac{\partial F}{\partial x}\,\frac{dx}{dx} + \frac{\partial F}{\partial y}\,\frac{dy}{dx} = 0 \quad\Longrightarrow\quad F_x + F_y\,\frac{dy}{dx} = 0.
Solving for the slope gives the compact implicit function formula
\frac{dy}{dx} = -\frac{F_x}{F_y}.
For the circle F_x = 2x, F_y = 2y, so
dy/dx = -x/y — the same answer the high-school "differentiate both
sides" trick produces, now revealed as a one-line corollary of the multivariable chain rule
(valid wherever F_y \ne 0).
The tree-diagram method is not just a teaching device — it is, quite literally, how every
neural network learns. A network is a giant composition of functions: raw inputs feed into a
layer, whose outputs feed the next layer, and so on until a single number comes out (the
"loss", how wrong the network's guess was). Training asks for the rate of change of that loss
with respect to every single weight buried deep inside the network — sometimes
billions of them.
Computing each one by brute force would be hopeless. Instead, the algorithm called
backpropagation is exactly the tree-diagram chain rule, scaled up: think of
the whole network as one enormous tree diagram, with the loss at the top and every weight at
the bottom. Backpropagation walks the tree once, from the loss back down towards the inputs,
multiplying local derivatives along each edge and adding them up wherever branches
merge — precisely the "multiply along the path, add across paths" rule from the
theorem above, just repeated millions of times by a computer instead of twice by hand. The
two-parameter example — one weight influencing the answer through several intermediate
routes, each contribution multiplied and then summed — is the whole idea already, in
miniature.