Chain Rule for Multivariable Functions
What You’ll Learn
Section titled “What You’ll Learn”In this lesson you’ll learn how to differentiate composite functions where the variables themselves depend on other variables. The tree diagram method will become your go-to tool for keeping track of all the dependency paths.
The Concept
Section titled “The Concept”Why We Need a New Chain Rule
Section titled “Why We Need a New Chain Rule”In Calculus 1, the chain rule was straightforward: if y = f(g(x)), then dy/dx = f’(g(x)) g’(x). One function inside another, one path.
In multivariable calculus, a function z = f(x, y) might have x and y that each depend on other variables. Now there are multiple paths from z to the variable you’re differentiating with respect to, and you need to account for all of them.
Case 1: One Parameter
Section titled “Case 1: One Parameter”If z = f(x, y) where x = x(t) and y = y(t), then z ultimately depends on just t through two paths
Each term represents one path: z changes because x changes with t, and z also changes because y changes with t. Add them up.
Case 2: Two Parameters
Section titled “Case 2: Two Parameters”If z = f(x, y) where x = x(s, t) and y = y(s, t), then
The Tree Diagram
Section titled “The Tree Diagram”The tree diagram is the easiest way to never miss a term. Draw the function at the top, its immediate variables below, and the final variables at the bottom. Each edge gets labeled with the appropriate derivative. To find a total derivative, trace every path from top to bottom and multiply along each path, then add all paths.
You don’t need the tree diagram to use the chain rule. You can always just write out the formula directly. But when the dependencies get complicated, the tree is a cool trick that makes it almost impossible to forget a term.
Worked Examples
Section titled “Worked Examples”Example 1: Single parameter
Let z = x² + 3xy + y² where x = t² and y = 3t. Find dz/dt.
First, compute the partial derivatives of z
Then the derivatives of x and y with respect to t
Apply the chain rule
At t = 1 (so x = 1, y = 3)
Example 2: Two parameters with exponentials
Let z = where x = s + t and y = s - t. Find ∂z/∂s and ∂z/∂t.
The partials of z
The partials of x and y
Apply the chain rule for each
The two green circles at the bottom of the tree are s and t, the independent variables we’re differentiating with respect to. Two paths reach s (through x and through y), giving ∂z/∂s. Two paths reach t, giving ∂z/∂t. Multiply along each path, then add
Substituting back: since x + y = 2s and y - x = -2t
Example 3: Verifying by direct substitution
We can check Example 1 by substituting first. With x = t² and y = 3t
At t = 1: dz/dt = 4 + 27 + 18 = 49. Same answer as the chain rule gave us. Both methods work, but the chain rule is often faster when you don’t want to (or can’t) substitute everything first.
Real-World Application
Section titled “Real-World Application”The multivariable chain rule is everywhere:
- Machine learning uses it as backpropagation: the loss depends on outputs, which depend on weights, which depend on earlier layers. The chain rule traces every path backward through the network.
- Game engines use it when a character’s hand position depends on shoulder angle, elbow angle, and wrist angle, all changing with time. The chain rule computes the hand’s velocity.
- Physics uses it for related rates in 3D: pressure depends on temperature and volume, which both depend on time.
- Engineering uses it for sensitivity analysis: how does a final measurement change when multiple input parameters shift?