brand banner

Why the Multivariate Chain Rule Is a Sum

As t moves, x and y move at once. The rate of change of f is the directional derivative along the velocity (x'(t), y'(t)), and a dot product is a sum — so each intermediate variable contributes its own term.

Updated · 10 min read · #comp4102 · #calculus · #machine-learning

Why the Multivariate Chain Rule Is a Sum

As t moves, x and y move at once. The rate of change of f is the directional derivative along the velocity (x'(t), y'(t)), and a dot product is a sum — so each intermediate variable contributes its own term.

The question

Let 𝑧=𝑓(𝑥,𝑦), where 𝑥 and 𝑦 are themselves functions of a single variable 𝑡:

𝑔(𝑡)=𝑓(𝑥(𝑡),𝑦(𝑡)).

The single-variable chain rule says: differentiate the outside, times the derivative of the inside. But here there are two insides, 𝑥(𝑡) and 𝑦(𝑡), and both are moving at once. Which one do you multiply by? The answer is: both — and you add the results:

d𝑔d𝑡=𝜕𝑓𝜕𝑥d𝑥d𝑡+𝜕𝑓𝜕𝑦d𝑦d𝑡.

This note explains why the plus sign is there, and why it could not be anything else. The short version: 𝑔′(𝑡) is a directional derivative, taken in the direction the point (𝑥(𝑡),𝑦(𝑡)) is actually moving. A directional derivative is a dot product, and a dot product is a sum.

Directional derivatives: how fast does f change in a given direction?

Stand at a point 𝑝=(𝑥,𝑦) and walk in a direction given by a unit vector 𝑢=(𝑢1,𝑢2). The directional derivative 𝐷𝑢𝑓(𝑝) is the rate at which 𝑓 changes per unit distance walked in that direction:

𝐷𝑢𝑓(𝑝)=limℎ→0𝑓(𝑝+ℎ𝑢)−𝑓(𝑝)ℎ.

If 𝑓 is differentiable, this limit has a closed form in terms of the gradient

∇𝑓=(𝜕𝑓𝜕𝑥,𝜕𝑓𝜕𝑦),

namely

𝐷𝑢𝑓(𝑝)=∇𝑓(𝑝)⋅𝑢=𝜕𝑓𝜕𝑥𝑢1+𝜕𝑓𝜕𝑦𝑢2.

Read that dot product as a sentence: the 𝑥-component of the direction, 𝑢1, is weighted by how sensitive 𝑓 is to 𝑥; the 𝑦-component, 𝑢2, is weighted by how sensitive 𝑓 is to 𝑦; then add. Each coordinate contributes its own term, because moving in direction 𝑢 means moving in 𝑥 and in 𝑦 at the same time.

Two facts about this formula do most of the work below:

  • The gradient ∇𝑓 points in the direction of steepest increase of 𝑓, and its length is the slope in that direction.
  • The dot product ∇𝑓⋅𝑢 is the component of the gradient along 𝑢: it measures how much of 𝑓’s steepness is aligned with the direction you are actually walking.

If 𝑢 is not a unit vector but a general vector 𝒗, the same dot product ∇𝑓⋅𝒗 still gives a rate of change — now per unit of whatever parameter 𝒗 is a velocity with respect to, rather than per unit distance. That distinction matters in the next section: our velocity is a velocity with respect to 𝑡, and 𝑔′(𝑡) is a rate per unit 𝑡.

The motion picks the direction

Now let the point move. As 𝑡 increases by a small amount Δ𝑡, the point (𝑥(𝑡),𝑦(𝑡)) moves by approximately

Δ𝑥≈𝑥′(𝑡)Δ𝑡,Δ𝑦≈𝑦′(𝑡)Δ𝑡.

So the point is travelling, at this instant, in the direction of the velocity vector

𝒗=(𝑥′(𝑡),𝑦′(𝑡)).

The rate at which 𝑓 changes as the point sweeps along is therefore the directional derivative of 𝑓 in the direction 𝒗 — the rate per unit 𝑡 along this motion:

𝑔′(𝑡)=𝐷𝒗𝑓=∇𝑓⋅𝒗.

That is the whole argument in one line. Everything after this is just expanding the dot product.

The diagram shows the motion at one instant: the point (𝑥(𝑡),𝑦(𝑡)), its velocity 𝒗 (red), and the velocity split into its horizontal part 𝑥′(𝑡) and its vertical part 𝑦′(𝑡) (blue). The motion is one arrow, but it has two components — and each component will contribute one term.

Expanding the dot product gives the sum

Write out ∇𝑓⋅𝒗 component by component:

𝑔′(𝑡)=∇𝑓⋅𝒗=(𝜕𝑓𝜕𝑥,𝜕𝑓𝜕𝑦)⋅(𝑥′(𝑡),𝑦′(𝑡))=𝜕𝑓𝜕𝑥𝑥′(𝑡)+𝜕𝑓𝜕𝑦𝑦′(𝑡).

That is Eq. 2. Each term has the same shape — sensitivity times speed — and the two terms are added because the dot product adds them:

  • 𝜕𝑓𝜕𝑥𝑥′(𝑡): how much 𝑓 changes because 𝑥 is moving, holding 𝑦 fixed. The partial derivative 𝜕𝑓𝜕𝑥 is the sensitivity to 𝑥; 𝑥′(𝑡) is how fast 𝑥 is moving.
  • 𝜕𝑓𝜕𝑦𝑦′(𝑡): how much 𝑓 changes because 𝑦 is moving, holding 𝑥 fixed.

If only 𝑥 moved (𝑦′(𝑡)=0), the second term would vanish and you would recover the single-variable chain rule. If only 𝑦 moved, the first term would vanish. In general both move, so both terms are present.

Why a sum, not a product?

The linear approximation makes the addition unavoidable. For small displacements,

Δ𝑓≈𝜕𝑓𝜕𝑥Δ𝑥+𝜕𝑓𝜕𝑦Δ𝑦.

Small changes in 𝑓 add: a nudge in 𝑥 changes 𝑓 by roughly 𝜕𝑓𝜕𝑥Δ𝑥, a nudge in 𝑦 changes it by roughly 𝜕𝑓𝜕𝑦Δ𝑦, and to first order the two nudges do not interfere with each other. Divide by Δ𝑡 and let Δ𝑡→0:

d𝑓d𝑡≈𝜕𝑓𝜕𝑥Δ𝑥Δ𝑡+𝜕𝑓𝜕𝑦Δ𝑦Δ𝑡→𝜕𝑓𝜕𝑥𝑥′(𝑡)+𝜕𝑓𝜕𝑦𝑦′(𝑡).

A product would come from a term like Δ𝑥Δ𝑦, but that is second order — it shrinks like (Δ𝑡)2, so it disappears in the limit. The derivative only sees first-order effects, and first-order effects add. This is the same reason the total differential is a sum:

d𝑓=𝜕𝑓𝜕𝑥d𝑥+𝜕𝑓𝜕𝑦d𝑦,

and dividing by d𝑡 gives Eq. 2 again.

Worked example: check it both ways

Take

𝑓(𝑥,𝑦)=𝑥2𝑦,𝑥(𝑡)=2𝑡,𝑦(𝑡)=3𝑡.

Directly. Substitute first, then differentiate:

𝑔(𝑡)=(2𝑡)2(3𝑡)=12𝑡3,𝑔′(𝑡)=36𝑡2.

By the chain rule. The partials are 𝑓𝑥=2𝑥𝑦 and 𝑓𝑦=𝑥2, and 𝑥′(𝑡)=2, 𝑦′(𝑡)=3, so

𝑔′(𝑡)=2𝑥𝑦⏟𝑓𝑥⋅2⏟𝑥′+𝑥2⏟𝑓𝑦⋅3⏟𝑦′=2(2𝑡)(3𝑡)⋅2+(2𝑡)2⋅3=24𝑡2+12𝑡2=36𝑡2.

The two routes agree, as they must. At 𝑡=1 the contributions are easy to read off:

| Channel | Sensitivity | Speed | Contribution | | — | — | — | — | | through 𝑥 | 𝑓𝑥=12 | 𝑥′=2 | 24 | | through 𝑦 | 𝑓𝑦=4 | 𝑦′=3 | 12 | | total | | | 36 |

The 𝑥-channel contributes twice as much as the 𝑦-channel here, even though 𝑓 is “more sensitive” to 𝑦 in isolation at some points — what matters is sensitivity times speed along the actual motion.

A second example: contributions can cancel

Suppose that at some instant

∇𝑓=(3,−1),𝒗=(𝑥′(𝑡),𝑦′(𝑡))=(2,1).

Then

𝑔′(𝑡)=∇𝑓⋅𝒗=3⋅2+(−1)⋅1=6−1=5.

Moving in 𝑥 alone would push 𝑓 up at rate 6; moving in 𝑦 alone would pull it down at rate 1. Moving in both at once, the net rate is 5. The sum is doing real work here: it lets the two channels partly cancel. A product could never produce that — it could not even get the sign right in general, since a product of a positive and a negative contribution is negative, while the sum can be either.

Geometrically, 𝑔′(𝑡)=|∇𝑓||𝒗|cos𝜃, where 𝜃 is the angle between the gradient and the velocity. The rate is largest when the motion aligns with the gradient, zero when the motion is perpendicular to it (you are walking along a level curve), and negative when the motion opposes the gradient. All of that is the dot product talking — and the dot product is a sum over coordinates.

The general form, and backprop

With 𝑛 intermediate variables 𝑥1(𝑡),…,𝑥𝑛(𝑡) and 𝑔(𝑡)=𝑓(𝑥1(𝑡),…,𝑥𝑛(𝑡)), the same argument gives one term per variable:

𝑔′(𝑡)=∑𝑖=1𝑛𝜕𝑓𝜕𝑥𝑖d𝑥𝑖d𝑡=∇𝑓⋅𝒓′(𝑡),

where 𝒓(𝑡)=(𝑥1(𝑡),…,𝑥𝑛(𝑡)). In matrix form this is a 1×𝑛 Jacobian times an 𝑛×1 Jacobian — and matrix multiplication is itself a sum over the shared index. The plus sign in the chain rule and the plus sign in matrix multiplication are the same plus sign.

This is also why backpropagation sums over paths. If a loss 𝐿 depends on a weight 𝑤 through several activations 𝑎1,𝑎2,…, then

𝜕𝐿𝜕𝑤=∑𝑗𝜕𝐿𝜕𝑎𝑗𝜕𝑎𝑗𝜕𝑤:

each path from 𝑤 to 𝐿 contributes its own sensitivity-times-speed term, and the total gradient is the sum over paths. A node that feeds the loss through two routes contributes twice — once per route — for exactly the reason above: the point is moving in two coordinates at once, and first-order changes add.

Checklist and pitfalls

  • Partial vs total. In Eq. 2, 𝜕𝑓𝜕𝑥 holds 𝑦 fixed, while d𝑔d𝑡 is the total rate along the motion. Do not swap them: 𝜕𝑓𝜕𝑡 would be meaningless here, since 𝑓 has no 𝑡 argument of its own.
  • Differentiability matters. The argument needs 𝑓 differentiable at (𝑥(𝑡),𝑦(𝑡)) and 𝑥,𝑦 differentiable at 𝑡. Mere existence of the partials is not quite enough in pathological cases; continuous partials are a safe sufficient condition.
  • If 𝑓 also depends on 𝑡 directly, say 𝑔(𝑡)=𝑓(𝑥(𝑡),𝑦(𝑡),𝑡), there is one more channel — time itself — and one more term: 𝜕𝑓𝜕𝑡.
  • Units check. Each term is (change in 𝑓 per unit 𝑥) times (change in 𝑥 per unit 𝑡), i.e. change in 𝑓 per unit 𝑡 — as it must be, since all terms are added to give 𝑔′(𝑡).


© 2026 James Yap

Personal Website and Knowledge Base