You're staring at a function like z = f(x, y)* where x = g(t)* and y = h(t), and you need dz/dt. So your professor derived it in three lines. So naturally, you nodded along. Then you got to the homework and realized you have no idea which derivative goes where Which is the point..
No fluff here — just what actually works Small thing, real impact..
Sound familiar?
The chain rule for multiple variables isn't harder than the single-variable version. Day to day, it's just... In practice, messier. Plus, more moving parts. More places to lose track of what depends on what. And most textbooks explain it by throwing a tree diagram at you and calling it a day.
Let's actually walk through it. No tree diagrams required — unless you want one.
What Is the Chain Rule for Partial Derivatives
At its core, the chain rule answers one question: if I wiggle the input, how does the output change — when the input affects the output through intermediate variables?*
Single variable: y = f(u), u = g(x). Plus, then dy/dx = (dy/du)(du/dx). Day to day, it's a chain. You learned this in Calc I. One link after another.
Multiple variables: z = f(x, y)* where x = g(s, t)* and y = h(s, t). Wiggle s — x changes, y changes, both affect z. Now z depends on s and t through two intermediate variables. The total effect is the sum of both pathways Easy to understand, harder to ignore..
That's it. That's the whole intuition. Every formula you'll see is just bookkeeping for "sum over all pathways.
The Two Main Flavors
You'll encounter two setups constantly:
Case 1: One independent variable
z = f(x, y), x = g(t), y = h(t)* → find dz/dt*
This is the direct generalization of the single-variable chain rule.
Case 2: Two (or more) independent variables
z = f(x, y), x = g(s, t), y = h(s, t)* → find ∂z/∂s and ∂z/∂t
This is where partial derivatives enter the picture. You're holding one independent variable fixed while differentiating with respect to the other It's one of those things that adds up..
There's also Case 3: Mixed dependencies — z = f(x, y), x = g(s, t), y = h(t)* where y doesn't depend on s. The rule still works; you just have fewer pathways Worth keeping that in mind..
Why It Matters / Why People Care
You might wonder: when would I ever actually use this?*
Short answer: constantly. Any time a quantity depends on other quantities that themselves depend on something else — which is basically every real-world model.
Physics: temperature T at a point (x, y, z) in a room, but you're moving along a path (x(t), y(t), z(t)). Because of that, how fast does the temperature you feel change? dT/dt = ∂T/∂x dx/dt + ∂T/∂y dy/dt + ∂T/∂z dz/dt*. That's the chain rule.
Economics: profit P depends on labor L and capital K. But L and K depend on time t and interest rate r. You need ∂P/∂r to understand how policy changes affect the bottom line.
Machine learning: backpropagation is the chain rule for partial derivatives, applied to a computational graph with millions of variables. Every gradient calculation in a neural network is a chain rule computation.
Implicit differentiation? Even so, chain rule. Related rates? Even so, chain rule. Because of that, change of variables in integrals? Chain rule (the Jacobian determinant is the multivariable chain rule in disguise).
If you're shaky on this, everything downstream gets shakier Most people skip this — try not to..
How It Works
Let's derive the formulas from scratch. Not because you need to re-derive them on exams — you don't — but because seeing where they come from makes them impossible to forget.
Case 1: One Independent Variable (t)
z = f(x, y)*
x = g(t)*
y = h(t)*
Assume f, g, h* are differentiable. z is ultimately a function of t alone. By definition of the derivative:
dz/dt = lim_{Δt→0} [f(x(t+Δt), y(t+Δt)) - f(x(t), y(t))] / Δt*
Add and subtract f(x(t+Δt), y(t))* in the numerator:
= lim [f(x(t+Δt), y(t+Δt)) - f(x(t+Δt), y(t))] / Δt + lim [f(x(t+Δt), y(t)) - f(x(t), y(t))] / Δt
First term: y changes, x held at x(t+Δt). But as Δt→0, x(t+Δt)→x(t). This becomes ∂f/∂y · dy/dt.
Second term: x changes, y held fixed at y(t)*. Becomes ∂f/∂x · dx/dt.
Result:
dz/dt = ∂f/∂x · dx/dt + ∂f/∂y · dy/dt*
Notice the pattern: ∂f/∂(intermediate) × d(intermediate)/dt, summed over all intermediates.
Case 2: Two Independent Variables (s, t*)
z = f(x, y)*
x = g(s, t)*
y = h(s, t)*
Now z is a function of s and t. To find ∂z/∂s, treat t as constant and differentiate with respect to s. Exact same logic as Case 1, but with partials:
∂z/∂s = ∂f/∂x · ∂x/∂s + ∂f/∂y · ∂y/∂s
Similarly:
∂z/∂t = ∂f/∂x · ∂x/∂t + ∂f/∂y · ∂y/∂t
The General Pattern (Memorize This, Not the Formulas)
For z = f(u₁, u₂, ..., uₙ)* where each uᵢ = uᵢ(v₁, v₂, ..., vₘ)*:
∂z/∂vⱼ = Σᵢ (∂f/∂uᵢ) · (∂uᵢ/∂vⱼ)
Sum over all intermediate variables uᵢ. Each term: derivative of outer function with respect to that intermediate, times derivative of that intermediate with respect to the variable you're differentiating.
That's the only formula you need. Everything else is a special case.
A Concrete Example
z = x²y + sin(y)*
x = s + t*
y = st*
Find ∂z/∂s and ∂z/∂t.
First, compute the partials of z with respect to its
direct inputs:
∂z/∂x = 2xy
∂z/∂y = x² + cos(y)
Next, determine how x and y respond to changes in s and t:
∂x/∂s = 1
∂x/∂t = 1
∂y/∂s = t
∂y/∂t = s
Now apply the general pattern. For ∂z/∂s:
∂z/∂s = (∂z/∂x)(∂x/∂s) + (∂z/∂y)(∂y/∂s)
= (2xy)(1) + (x² + cos(y))(t)
= 2xy + t(x² + cos(y))
Substituting back x = s + t and y = st:
∂z/∂s = 2(s + t)(st) + t[(s + t)² + cos(st)]
For ∂z/∂t:
∂z/∂t = (∂z/∂x)(∂x/∂t) + (∂z/∂y)(∂y/∂t)
= (2xy)(1) + (x² + cos(y))(s)
= 2xy + s(x² + cos(y))
Substituting the same expressions:
∂z/∂t = 2(s + t)(st) + s[(s + t)² + cos(st)]
Why This Matters
The chain rule isn't just calculus—it's the backbone of modern computational thinking. In machine learning, when you adjust weights in a neural network, you're implicitly computing chain rule derivatives through layers of transformations. In economics, when interest rates shift and ripple through financial models, you're seeing the chain rule in action Turns out it matters..
People argue about this. Here's where I land on it.
The pattern is always the same: identify your intermediate variables, compute their rates of change, multiply by how your final output depends on them, then sum across all paths. Master this, and you'll recognize it everywhere—from thermodynamics to computer graphics to financial modeling.
The chain rule teaches us that complex systems rarely change for just one reason. Here's the thing — understanding those multiple influences requires breaking down composite relationships into their constituent derivatives. That decomposition—the ability to see how changes propagate through interconnected systems—is what makes the chain rule indispensable The details matter here..
Visualizing the Flow: Tree Diagrams
When the number of variables grows, a tree diagram keeps the accounting straight. Draw the dependent variable $z$ at the top. Branch downward to the intermediate variables ($x, y$). In real terms, branch again to the independent variables ($s, t$). Every path from $z$ to the target variable represents a term in the sum It's one of those things that adds up..
z
/ \
x y
/ \ / \
s t s t
To find $\partial z/\partial s$, trace every path from $z$ to $s$:
- $z \to x \to s$ $\implies \frac{\partial z}{\partial x} \frac{\partial x}{\partial s}$
- $z \to y \to s$ $\implies \frac{\partial z}{\partial y} \frac{\partial y}{\partial s}$
Sum them. The diagram makes the general pattern $\partial z/\partial v_j = \sum_i (\partial f/\partial u_i)(\partial u_i/\partial v_j)$ visually obvious: sum over all paths connecting the output to the input.
Case 3: Nested Dependencies (The "Real World" Scenario)
Often, intermediate variables depend on each other*, not just on the root inputs. Suppose: $z = f(x, y), \quad x = g(s, t), \quad y = h(x, t)$ Here $y$ depends on $x$ explicitly. The tree grows a cross-branch:
z
/ \
x y
/ \ ↑
s t └── (y depends on x too)
Now $\partial z/\partial s$ requires the chain rule inside* the chain rule. Start with the general pattern: $\frac{\partial z}{\partial s} = \frac{\partial z}{\partial x}\frac{\partial x}{\partial s} + \frac{\partial z}{\partial y}\frac{\partial y}{\partial s}$
But $\partial y/\partial s$ isn't a primitive—it must be expanded because $y = h(x, t)$ and $x = g(s, t)$: $\frac{\partial y}{\partial s} = \frac{\partial h}{\partial x}\frac{\partial x}{\partial s} + \frac{\partial h}{\partial t}\underbrace{\frac{\partial t}{\partial s}}_{=0} = \frac{\partial y}{\partial x}\frac{\partial x}{\partial s}$
Substitute back: $\frac{\partial z}{\partial s} = \frac{\partial z}{\partial x}\frac{\partial x}{\partial s} + \frac{\partial z}{\partial y}\left(\frac{\partial y}{\partial x}\frac{\partial x}{\partial s}\right)$ Factor out $\partial x/\partial s$: $\frac{\partial z}{\partial s} = \left( \frac{\partial z}{\partial x} + \frac{\partial z}{\partial y}\frac{\partial y}{\partial x} \right) \frac{\partial x}{\partial s}$
The lesson: The tree diagram still works. Just follow every* directed path from $z$ to $s$. The cross-branch $y \leftarrow x$ creates a second path: $z \to y \to x \to s$. The algebraic sum of paths handles the nesting automatically It's one of those things that adds up..
Common Pitfalls (And How to Avoid Them)
1. Confusing $\partial z/\partial x$ with $dz/dx$ In Case 2, $z = f(x,y)$ and $x=g(s,t)$. The symbol $\partial z/\partial x$ means "hold $y$ constant, vary $x$." It is a property of $f$ alone. It does not mean "total derivative of $z$ with respect to $x$ accounting for how $y$ changes with $x$." Label your derivatives carefully: $f_x$, $g_s$, $h_t$ removes ambiguity.
2. Forgetting to Evaluate at the Correct Point If asked for $\partial z/\partial s$ at $(s,t)=(1,2)$, you must compute $
the partial derivatives for every function in the chain first, and then* plug in the values. A common mistake is to plug in the values too early, especially if the variables are linked through intermediate functions. Always maintain the functional form until the final summation step.
3. Misinterpreting the "Constant" Variable When calculating $\partial z/\partial x$ in a multivariable context, you are implicitly assuming all other variables (like $y$) are constant. Even so, if $y$ is actually a function of $x$, the partial* derivative $\partial z/\partial x$ ignores that connection, whereas the total* derivative accounts for it. If you are traversing a computational graph, you must distinguish between "local" partial derivatives (the edges in your diagram) and the "global" total derivative (the sum of the paths) Worth knowing..
Summary Table: The Computational Perspective
To solidify your intuition, view the chain rule through the lens of a computer scientist or a machine learning engineer. In modern neural networks, this is known as Backpropagation Easy to understand, harder to ignore..
| Concept | Mathematical View | Computational View |
|---|---|---|
| Forward Pass | Evaluating $f(g(s))$ | Calculating values from inputs to output. |
| Chain Rule | $\frac{dz}{ds} = \frac{dz}{dx} \cdot \frac{dx}{ds}$ | Multiplying local gradients along a path. |
| Complexity | Summing paths in a tree | Accumulating gradients via "Backprop. |
Conclusion
The chain rule is often taught as a rigid formula to be memorized, but it is actually a geometric principle. Whether you are dealing with simple direct dependencies or complex, nested architectures where variables influence one another through multiple channels, the rule remains the same: The total change in an output is the sum of the changes propagated through every possible path.
By visualizing dependencies as a directed graph, you transform a daunting algebraic problem into a simple task of pathfinding. Once you master the ability to trace these paths and correctly distinguish between local partial derivatives and global total derivatives, you possess the fundamental tool required for multivariable calculus, thermodynamics, and the training of deep neural networks Most people skip this — try not to..