Skip to content
Tutorials Center
My learning

Topics

Lesson 13 of 39 · Partial Derivatives

The Chain Rule for Several Variables

Master the multivariable chain rule with tree diagrams: derivatives along curves, functions of several intermediate variables, and related rates, with sympy.

In one variable, if y = f(u) and u = g(x), then dy/dx = f'(u) g'(x). With several variables there may be several paths by which a change in x reaches the final output. The chain rule adds up all of these paths.

Case 1: one parameter

Let z = f(x, y) where x = x(t) and y = y(t). Then z depends on t through two routes:

Text
dz/dt = (∂f/∂x)(dx/dt) + (∂f/∂y)(dy/dt)

Worked example: z = x²y + y³, x = cos t, y = sin t. Then z_x = 2xy, z_y = x² + 3y², x' = -sin t, y' = cos t:

Text
dz/dt = 2 cos t sin t (-sin t) + (cos² t + 3 sin² t)(cos t)

At t = π/2: cos t = 0, sin t = 1, so dz/dt = 0 + (0 + 3)(0) = 0.

You can also write z as a function of t directly and differentiate, to check.

Python Chain rule vs direct substitution

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A tree diagram

Draw a diagram: the output at the top, its immediate inputs below, then what they depend on. Multiply along each branch, add the branches.

flowchart TD
    z["z = f(x, y)"] -->|"∂z/∂x"| x["x(s, t)"]
    z -->|"∂z/∂y"| y["y(s, t)"]
    x -->|"∂x/∂s"| s["s"]
    x -->|"∂x/∂t"| t["t"]
    y -->|"∂y/∂s"| s
    y -->|"∂y/∂t"| t

Tree diagram for z = f(x, y) with x and y each depending on s and t.

Case 2: several parameters

If z = f(x, y) with x = x(s, t) and y = y(s, t), then

Text
∂z/∂s = (∂z/∂x)(∂x/∂s) + (∂z/∂y)(∂y/∂s)
∂z/∂t = (∂z/∂x)(∂x/∂t) + (∂z/∂y)(∂y/∂t)

Worked example: z = e^(xy), x = s + t, y = s - t. Then z_x = y e^(xy), z_y = x e^(xy):

Text
∂z/∂s = y e^(xy) · 1 + x e^(xy) · 1 = (x + y) e^(xy) = 2s e^(s² - t²)
∂z/∂t = y e^(xy) · 1 + x e^(xy) · (-1) = (y - x) e^(xy) = -2t e^(s² - t²)

(Because x + y = 2s, y - x = -2t, and xy = s² - t².)

Python Two-parameter chain rule

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Polar coordinates

A frequent application: change f(x, y) to polar coordinates with x = r cos θ, y = r sin θ. Then

Text
∂f/∂r = f_x cos θ + f_y sin θ
∂f/∂θ = -f_x r sin θ + f_y r cos θ

This lets you rewrite the Laplacian or study rotation. For f = x² + y², ∂f/∂r = 2x cos θ + 2y sin θ = 2r, and ∂f/∂θ = 0, as expected because f = r² does not change as you rotate.

Chain rule recipe

Draw a tree Output at the top
Multiply Along each branch
Add All branches that reach the variable
1 / 2

The chain rule turns "how fast is this changing?" questions into computations.

Worked example: the radius of a cone grows at 2 cm/s and its height shrinks at 3 cm/s. How fast does the volume V = (1/3)π r² h change when r = 4 and h = 9? V_r = (2/3)π r h = 24π, V_h = (1/3)π r² = 16π/3. So dV/dt = 24π(2) + (16π/3)(-3) = 48π - 16π = 32π ≈ 100.5 cm³/s.

Python Cone volume rate

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. If z = f(x, y), x = x(t), y = y(t), then dz/dt equals

    Add the contribution through x and the contribution through y.
  2. 2. For z = xy with x = t² and y = t³, dz/dt is

    z = t⁵, so dz/dt = 5t⁴; the chain rule gives y(2t) + x(3t²) = 2t⁴ + 3t⁴ = 5t⁴.
  3. 3. In polar coordinates, ∂f/∂r equals

    ∂x/∂r = cos θ and ∂y/∂r = sin θ.
  4. 4. In a tree diagram for the chain rule, you

    Each path contributes a product of derivatives; all paths are summed.

Summary

  • dz/dt = f_x x' + f_y y' for one parameter; with two parameters, use the same sum for each partial.
  • Tree diagrams organize the bookkeeping.
  • Polar coordinates and related-rates problems are standard applications.
  • Always verify by direct substitution when possible.

Next: Implicit Differentiation with Partial Derivatives