Multivariable Chain Rule
The multivariable chain rule finds the derivative of a function whose inputs depend on other variables. If z = f(x, y) with x = x(t) and y = y(t), then dz/dt = (∂z/∂x)(dx/dt) + (∂z/∂y)(dy/dt). Each path from z down to t in a tree diagram gives one product, and you add the products.
Before this lesson: Chain Rule, Partial Derivatives and Vector Functions and Space Curves
Why the chain rule has more than one term
Suppose z = f(x, y) and both x and y change with time t. A small step in t moves x a little and moves y a little. Each of those moves changes z, so the total change in z is the sum of two effects.
The x effect is (rate z changes with x) × (rate x changes with t), and the y effect works the same way. That is why the multivariable chain rule is a sum of products, one product for each input.
Multivariable chain rule formulas
Case 1: one independent variable. If z = f(x, y), x = x(t) and y = y(t):
\dfrac{dz}{dt} = \dfrac{\partial z}{\partial x}\dfrac{dx}{dt} + \dfrac{\partial z}{\partial y}\dfrac{dy}{dt}Case 2: two independent variables. If z = f(x, y), x = x(s, t) and y = y(s, t):
\dfrac{\partial z}{\partial s} = \dfrac{\partial z}{\partial x}\dfrac{\partial x}{\partial s} + \dfrac{\partial z}{\partial y}\dfrac{\partial y}{\partial s}, \qquad \dfrac{\partial z}{\partial t} = \dfrac{\partial z}{\partial x}\dfrac{\partial x}{\partial t} + \dfrac{\partial z}{\partial y}\dfrac{\partial y}{\partial t}- Tree diagram rule: draw the function at the top, its inputs below it, and their inputs below those. For each path from the top down to the variable you want, multiply the derivatives on the branches. Then add the products.
- More variables: w = f(x, y, z) has three branches at the top, so its chain rule has three terms.
- Implicit differentiation: if F(x, y) = 0 defines y as a function of x, then \dfrac{dy}{dx} = -\dfrac{F_x}{F_y} wherever F_y \ne 0.
- Use d for a derivative when there is one independent variable (dz/dt) and ∂ when there are several (∂z/∂s).
Multivariable chain rule examples
Example 1: One parameter
Let z = x²y, with x = t² and y = 3t + 1. Find dz/dt at t = 1.
\dfrac{\partial z}{\partial x} = 2xy, \quad \dfrac{\partial z}{\partial y} = x^2Find the partial derivatives of z.
\dfrac{dx}{dt} = 2t, \quad \dfrac{dy}{dt} = 3Differentiate x and y with the power rule.
\dfrac{dz}{dt} = 2xy(2t) + x^2(3)Use the chain rule: one product for each path.
x = 1^2 = 1, \quad y = 3(1) + 1 = 4
Find x and y at t = 1.
\dfrac{dz}{dt} = 2(1)(4)(2) + (1)^2(3)Substitute x = 1, y = 4 and t = 1.
= 16 + 3
Multiply.
= 19
Add.
Answer: dz/dt = 19 at t = 1. Check: z = t⁴(3t + 1) = 3t⁵ + t⁴, so dz/dt = 15t⁴ + 4t³ = 19 at t = 1.
Example 2: Two independent variables
Let z = e^(xy), with x = s + t and y = s − t. Find ∂z/∂s and ∂z/∂t in terms of s and t.
\dfrac{\partial z}{\partial x} = ye^{xy}, \quad \dfrac{\partial z}{\partial y} = xe^{xy}Partial derivatives of z (see derivatives of exponential functions).
\dfrac{\partial z}{\partial s} = ye^{xy}(1) + xe^{xy}(1)Paths to s: ∂x/∂s = 1 and ∂y/∂s = 1.
= (x + y)e^{xy}Factor out e^(xy).
= 2se^{s^2 - t^2}Substitute x + y = 2s and xy = (s + t)(s − t) = s² − t².
\dfrac{\partial z}{\partial t} = ye^{xy}(1) + xe^{xy}(-1)Paths to t: ∂x/∂t = 1 and ∂y/∂t = −1.
= (y - x)e^{xy}Factor out e^(xy).
= -2te^{s^2 - t^2}Substitute y − x = −2t and xy = s² − t².
Answer: ∂z/∂s = 2s e^(s² − t²) and ∂z/∂t = −2t e^(s² − t²).
Example 3: Three intermediate variables
Let w = x² + yz, with x = cos t, y = sin t and z = t. Find dw/dt at t = π/2.
\dfrac{dw}{dt} = 2x\dfrac{dx}{dt} + z\dfrac{dy}{dt} + y\dfrac{dz}{dt}Three inputs, so three products: ∂w/∂x = 2x, ∂w/∂y = z, ∂w/∂z = y.
= 2x(-\sin t) + z(\cos t) + y(1)
Differentiate x, y and z (see derivatives of trig functions).
x = 0, \quad y = 1, \quad z = \dfrac{\pi}{2}Evaluate x, y and z at t = π/2.
\dfrac{dw}{dt} = 2(0)(-1) + \dfrac{\pi}{2}(0) + 1(1)Substitute, using sin(π/2) = 1 and cos(π/2) = 0.
= 1
Multiply and add.
Answer: dw/dt = 1 at t = π/2.
Example 4: Implicit differentiation
Find dy/dx for the curve x³ + y³ = 6xy at the point (3, 3).
3^3 + 3^3 = 54 = 6(3)(3)
Check that (3, 3) is on the curve.
F(x, y) = x^3 + y^3 - 6xy
Move everything to one side so F(x, y) = 0.
F_x = 3x^2 - 6y
Partial with respect to x.
F_x(3, 3) = 27 - 18 = 9
Evaluate at (3, 3).
F_y = 3y^2 - 6x
Partial with respect to y.
F_y(3, 3) = 27 - 18 = 9
Evaluate at (3, 3).
\dfrac{dy}{dx} = -\dfrac{9}{9}Use dy/dx = −F_x/F_y.
= -1
Divide.
Answer: dy/dx = −1 at (3, 3). This matches what implicit differentiation from Calculus 1 gives, with less algebra.
Example 5: Two cars moving apart (word problem)
Car A is 30 miles north of an intersection, driving north at 50 mph. Car B is 40 miles east of it, driving east at 60 mph. How fast is the distance between the cars changing?
D = \sqrt{x^2 + y^2}Let x be car B’s distance east and y be car A’s distance north (see distance formula).
D = \sqrt{40^2 + 30^2} = 50Find the current distance.
\dfrac{\partial D}{\partial x} = \dfrac{x}{D}, \quad \dfrac{\partial D}{\partial y} = \dfrac{y}{D}Partial derivatives of D.
\dfrac{dD}{dt} = \dfrac{x}{D}\dfrac{dx}{dt} + \dfrac{y}{D}\dfrac{dy}{dt}Chain rule.
= \dfrac{40}{50}(60) + \dfrac{30}{50}(50)Substitute x = 40, y = 30, D = 50, dx/dt = 60 and dy/dt = 50.
= 48 + 30
Multiply.
= 78
Add.
Answer: the distance between the cars is growing at 78 mph.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Using only one path | For z = x²y: dz/dt = 2xy · dx/dt | Add a product for every input: dz/dt = 2xy · dx/dt + x² · dy/dt. |
| Multiplying the paths instead of adding | dz/dt = (2xy · 2t)(x² · 3) | Multiply along each path, then add the paths. |
| Plugging in t but not x and y | In Example 1, putting t = 1 into 2xy(2t) + x²(3) but leaving x and y as letters | Also find x and y at t = 1, then substitute every value. |
| Losing the minus sign in implicit form | dy/dx = Fx/Fy | The formula is dy/dx = −Fx/Fy. |
| “Canceling” the ∂x’s | (∂z/∂x)(∂x/∂s) = ∂z/∂s | One path is only part of the answer when z has more than one input. |
Related methods
Substitute first, then differentiate
For a single-variable answer, you can also substitute x(t) and y(t) into z and use the one-variable chain rule. This is a good way to check your work, as in Example 1. The multivariable chain rule is easier when the formulas are messy or when you only know rates at one moment, as in Example 5.
Connection to related rates and the gradient
Example 5 is a related rates problem solved with partial derivatives. In the next lesson, the chain rule for z = f(x(t), y(t)) is written as a dot product of the gradient with the velocity vector, which leads to directional derivatives.
Practice problems
- Let z = x² + y², x = 2t and y = t². Find dz/dt.
- Let z = xy, x = eᵗ and y = cos t. Find dz/dt.
- Let z = x/y, x = 3t and y = t + 1. Find dz/dt at t = 1.
- Let z = x²y, x = s + t and y = st. Find ∂z/∂s and ∂z/∂t at (s, t) = (1, 2).
- Let w = xyz, x = t, y = t² and z = t³. Find dw/dt.
- Let z = sin(x + y), x = s² and y = st. Find ∂z/∂t.
- Use the chain rule to find dy/dx for x² + xy + y² = 7 at (1, 2).
- Use the chain rule to find dy/dx for xy² + x³ = 10 at (1, 3).
- Let w = f(x, y, z), where x, y and z are functions of u and v. Write the chain rule for ∂w/∂u. How many terms does it have?
- A rectangle is 12 cm long and 5 cm wide. Its length grows 2 cm/s and its width shrinks 1 cm/s. How fast are its diagonal and its area changing?
Show answers
1.
\dfrac{dz}{dt} = 2x(2) + 2y(2t)∂z/∂x = 2x, dx/dt = 2, ∂z/∂y = 2y and dy/dt = 2t.
= 2(2t)(2) + 2(t^2)(2t)
Substitute x = 2t and y = t².
= 8t + 4t^3
Multiply.
Answer: dz/dt = 8t + 4t³
2.
\dfrac{dz}{dt} = y(e^t) + x(-\sin t)∂z/∂x = y and ∂z/∂y = x.
= e^t\cos t - e^t\sin t
Substitute x = eᵗ and y = cos t.
Answer: dz/dt = eᵗ(cos t − sin t)
3.
\dfrac{\partial z}{\partial x} = \dfrac{1}{y}, \quad \dfrac{\partial z}{\partial y} = -\dfrac{x}{y^2}Partials of x/y.
x = 3, \quad y = 2
Values at t = 1.
\dfrac{dz}{dt} = \dfrac{1}{2}(3) - \dfrac{3}{4}(1)Chain rule with dx/dt = 3 and dy/dt = 1.
= 1.5 - 0.75
Multiply.
= 0.75
Subtract.
Answer: dz/dt = 3/4 at t = 1
4.
x = 3, \quad y = 2
Values at s = 1 and t = 2.
\dfrac{\partial z}{\partial s} = 2xy(1) + x^2(t)∂x/∂s = 1 and ∂y/∂s = t.
= 2(3)(2) + 3^2(2)
Substitute x = 3, y = 2 and t = 2.
= 12 + 18
Multiply.
= 30
Add.
\dfrac{\partial z}{\partial t} = 2xy(1) + x^2(s)∂x/∂t = 1 and ∂y/∂t = s.
= 2(3)(2) + 3^2(1)
Substitute x = 3, y = 2 and s = 1.
= 12 + 9
Multiply.
= 21
Add.
Answer: ∂z/∂s = 30 and ∂z/∂t = 21 at (1, 2)
5.
\dfrac{dw}{dt} = yz(1) + xz(2t) + xy(3t^2)Three paths: ∂w/∂x = yz, ∂w/∂y = xz, ∂w/∂z = xy.
= t^5 + 2t^5 + 3t^5
Substitute x = t, y = t², z = t³ and multiply.
= 6t^5
Add.
Answer: dw/dt = 6t⁵ (check: w = t⁶)
6.
\dfrac{\partial z}{\partial t} = \cos(x + y)(0) + \cos(x + y)(s)∂x/∂t = 0 and ∂y/∂t = s.
= s\cos(s^2 + st)
Simplify and substitute x + y = s² + st.
Answer: ∂z/∂t = s cos(s² + st)
7.
F_x = 2x + y = 4
F = x² + xy + y² − 7; partial in x at (1, 2).
F_y = x + 2y = 5
Partial in y at (1, 2).
\dfrac{dy}{dx} = -\dfrac{4}{5}dy/dx = −F_x/F_y.
Answer: dy/dx = −4/5
8.
F_x = y^2 + 3x^2 = 9 + 3 = 12
F = xy² + x³ − 10; partial in x at (1, 3).
F_y = 2xy = 6
Partial in y at (1, 3).
\dfrac{dy}{dx} = -\dfrac{12}{6} = -2dy/dx = −F_x/F_y.
Answer: dy/dx = −2
9.
\dfrac{\partial w}{\partial u} = \dfrac{\partial w}{\partial x}\dfrac{\partial x}{\partial u} + \dfrac{\partial w}{\partial y}\dfrac{\partial y}{\partial u} + \dfrac{\partial w}{\partial z}\dfrac{\partial z}{\partial u}One product for each path from w down to u.
Answer: three terms, one for each of x, y and z.
10.
D = \sqrt{12^2 + 5^2} = 13Diagonal of the rectangle now.
\dfrac{dD}{dt} = \dfrac{12}{13}(2) + \dfrac{5}{13}(-1)Chain rule with ∂D/∂l = l/D and ∂D/∂w = w/D.
= \dfrac{24}{13} - \dfrac{5}{13}Multiply.
= \dfrac{19}{13}Subtract.
\approx 1.46
Divide.
\dfrac{dA}{dt} = w\dfrac{dl}{dt} + l\dfrac{dw}{dt}Chain rule for A = lw.
= 5(2) + 12(-1)
Substitute w = 5, l = 12, dl/dt = 2 and dw/dt = −1.
= 10 - 12
Multiply.
= -2
Subtract.
Answer: the diagonal grows about 1.46 cm/s, and the area shrinks 2 cm²/s.
Multivariable chain rule FAQ
What is the multivariable chain rule?
It is the rule for differentiating a function whose inputs depend on other variables. You multiply derivatives along each path from the function to the variable and add the results.
How do you use a tree diagram for the chain rule?
Put the function at the top, its inputs on the next row and their variables on the bottom row. Label each branch with a derivative. Every path to the variable you want gives one product.
How is it different from the single-variable chain rule?
The single-variable chain rule has one path, so it is one product, dy/dx = (dy/du)(du/dx). With several inputs there are several paths, so the answer is a sum of products.
How does the chain rule give dy/dx for an implicit curve?
If F(x, y) = 0, differentiating with the chain rule gives Fx + Fy(dy/dx) = 0. Solving gives dy/dx = −Fx/Fy.
Summary
- For z = f(x, y) with x(t) and y(t): dz/dt = (∂z/∂x)(dx/dt) + (∂z/∂y)(dy/dt).
- With x(s, t) and y(s, t), find ∂z/∂s and ∂z/∂t the same way, using partial derivatives on the bottom branches.
- Tree diagram: multiply along each path, then add the paths.
- Evaluate x, y and t together when you need a number.
- Implicit curves: dy/dx = −Fx/Fy.
Previous lesson: Tangent Planes
Next lesson: Directional Derivatives and the Gradient
Back to the Calculus 3 Index