The multivariable chain rule as a sum over paths
The question
Let z = x²y with x = t² and y = 3t − 1, so t reaches z through x and through y. How fast does z change at t = 1?
Stage 1 lets you build the answer from paths and checks it against a measured rate.
- 1 SeeTrace paths in four graphs.
- 2 TryFollow a point across contour lines.
- 3 ProveBuild the proof, line by line.
- 4 ApplyVolumes, option values and level curves.
Before you start · 3 quick checks on partial derivatives, the one-variable chain rule and the tangent plane, about 3 min
Two ideas before you start
2 ideasTwo routes from t to z
Figure: the graph of z(t) for z = xy, x = 2 + t, y = 1 − t², and a dashed line through the point at t = 0.5 with the slope of the chosen paths. It needs JavaScript.
dashed slope = ∂z/∂x · dx/dt = 0.75 + ∂z/∂y · dy/dt = −2.5
Here z = xy with x = 2 + t and y = 1 − t². Tap a button to change the dashed line.
When t moves, x and y both move, and each carries part of the change to z. The rate along one route is a product of rates, as in the one-variable chain rule.
Exact definition
The chain rule for two inputs. Let \(x(t)\) and \(y(t)\) be differentiable at \(t_0\), and let \(f(x, y)\) be differentiable at \((x(t_0), y(t_0))\) in the sense of the lesson on partial derivatives. Then \(z(t) = f(x(t), y(t))\) is differentiable at \(t_0\), and
\[\begin{aligned} \frac{dz}{dt} &= \frac{\partial z}{\partial x}\frac{dx}{dt} + \frac{\partial z}{\partial y}\frac{dy}{dt}, \end{aligned}\]where \(\partial z/\partial x = f_x\) and \(\partial z/\partial y = f_y\) are taken at \((x(t_0), y(t_0))\), and \(dx/dt\), \(dy/dt\) at \(t_0\). Each term is the rate along one route from \(t\) to \(z\). Stage 3 proves it.
Count every path
Figure: a dependency graph with the variables q, u, v and t. The variable q uses u and v, u uses t, and v uses u and t. It needs JavaScript.
Here q = f(u, v), u = g(t) and v = h(u, t). A path goes down one line at a time. Tap 2 or 3.
Draw a line from each variable to every variable its formula uses directly. A path runs from the top variable down to an independent one. Two paths can share a variable and still be different paths.
Exact definition
Dependency graph and paths. Each variable is a node. Draw an edge from a variable to each variable its formula uses directly; the independent variables have no formula and no edges below them. A path from \(z\) to \(t\) is a list of nodes \(z = v_0, v_1, \ldots, v_m = t\) in which each node's formula uses the next one. The rate of an edge from \(v\) to \(w\) is \(\partial v/\partial w\), the partial derivative of the formula of \(v\) in \(w\) with the other variables of that formula held fixed, written \(dv/dw\) when the formula uses \(w\) alone. All rates are taken at the current point.
The chain rule as a sum over paths. If every formula is differentiable at the current point, then the rate of \(z\) in \(t\), with the other independent variables held fixed, is the sum over all paths from \(z\) to \(t\) of the product of the edge rates along the path. Stage 3 proves the two-input case, and the box after the proof shows how the general case follows.
Fine print: d or ∂, and where the rates are taken
With one independent variable \(t\), the rate of \(z\) is written \(dz/dt\). With two or more, such as \(s\) and \(t\), the rate when only \(t\) changes is \(\partial z/\partial t\). An edge rate such as \(\partial z/\partial x\) holds the other variables of the formula for \(z\) fixed, while \(dz/dt\) lets everything that depends on \(t\) move. When \(t\) also appears directly in the formula for \(w\), the edge rate \(\partial w/\partial t\) and the total rate \(dw/dt\) are different rates: they have the same value only when the other paths from \(w\) to \(t\) add up to 0. Every rate is taken at the current point: \(\partial z/\partial x\) at the current values of \(x\) and \(y\), and \(dx/dt\) at the current \(t\). The graphs on this page have no loops: no variable depends, directly or through others, on itself.
Build the rate from paths
- Start at the top of the graph and press a variable button to go one line down. When you reach an independent variable, the path is added to your sum.
- Each path's rate is the product of the edge rates listed in the table. Your sum adds the paths you traced.
- Once you have traced a first path, the page measures the rate with a tiny step and shows how far your sum is from that measurement. A challenge is done when your sum has exactly the right paths.
- Undo steps back or removes the last path; Clear empties the sum.
| Edge | Rate |
|---|
Your sum is empty.
How the page measures the rate
The page computes the top variable from the formulas at the target variable plus 0.001 and minus 0.001, with every other independent variable held fixed, and divides the difference by 0.002. For the functions on this page this central difference is within 0.0001 of the true rate, so it is shown rounded to 3 decimal places with ≈. Your sum is exact: the edge rates are whole numbers here.
A point moving across contour lines
A point moves around the unit circle, \(x = \cos t\) and \(y = \sin t\), and \(z = xy\). Then \(\partial z/\partial x = y\), \(\partial z/\partial y = x\), \(dx/dt = -\sin t\) and \(dy/dt = \cos t\), so the two paths carry \(y\cdot(-\sin t)\) and \(x\cos t\).
The explorer and its goals open after you answer the prediction.
Goals
Why the paths add
Assumptions. Let \(I\) be an open interval containing \(t_0\), and let \(x\) and \(y\) be functions on \(I\) that are differentiable at \(t_0\); put \(a = x(t_0)\) and \(b = y(t_0)\). Let \(f\) be defined on an open set \(U\) of the plane that contains \((x(t), y(t))\) for every \(t\) in \(I\), and let \(f\) be differentiable at \((a, b)\): with \(r = \sqrt{h^2 + k^2}\), the error
\[\begin{aligned} e(h, k) &= f(a + h, b + k) - f(a, b) \\ &\quad - f_x(a, b)\,h - f_y(a, b)\,k \end{aligned}\]satisfies \(e(h, k)/r \to 0\) as \((h, k) \to (0, 0)\). Let \(z(t) = f(x(t), y(t))\) for \(t\) in \(I\).
Conclusion. \(z\) is differentiable at \(t_0\), and
\[\begin{aligned} z'(t_0) &= f_x(a, b)\,x'(t_0) \\ &\quad + f_y(a, b)\,y'(t_0). \end{aligned}\]Facts the proof uses. The sum and product laws for limits; a function with a derivative at a point is continuous there; a function that tends to 0 times a bounded function tends to 0.
Each line has one true option. Every wrong option is a false claim: it states a rule for every \(f\), \(x\) and \(y\) the theorem allows (or a fact about every step), and some allowed choice breaks it, as its feedback shows.
The same proof works for any number of inputs: if \(z = f(x_1, \ldots, x_n)\) with each \(x_i\) a function of \(t\), take \(r = \sqrt{h_1^2 + \cdots + h_n^2}\), and line 4 becomes \(z'(t_0) = \sum_i f_{x_i}\,x_i'(t_0)\), one term per input.
For a deeper graph, apply this rule one level at a time. Each input \(x_i\) has its own rate \(dx_i/dt\), which is again a sum over the paths from \(x_i\) to \(t\). Putting these sums into \(\sum_i f_{x_i}\,dx_i/dt\) and multiplying out gives one product for each way to go from \(z\) to an input and on to \(t\): one term per path from \(z\) to \(t\). An independent variable such as \(t\) that appears directly in \(f\) is an input with rate \(dt/dt = 1\), which is the direct path. With several independent variables, hold the others fixed: the paths that end at them carry rate 0.
The theorem needs \(x\) and \(y\) to be differentiable in \(t\). A standard Brownian path \(W_t\) is continuous but, with probability 1, has a derivative at no time. For a twice continuously differentiable \(f\), the change of \(f(W_t)\) over a step of length \(\Delta t\) has, next to the first-order term \(f'(W_t)\,\Delta W\), the second-order term \(\tfrac12 f''(W_t)(\Delta W)^2\), and \((\Delta W)^2\) has mean \(\Delta t\). Each such term shrinks with its step, but unless \(f'' = 0\), their sum over a fixed time interval does not in general tend to 0 as the steps shrink: Itô's lemma adds the term \(\tfrac12 f''(W_t)\,dt\).
Problems
Each problem has hints and a full solution. Exact answers are graded exactly: type a whole number, an exact decimal such as 0.25 or a fraction such as -1/2.
About P4: in the Black–Scholes model, with a positive starting price and a positive volatility, the stock price follows a geometric Brownian motion whose paths, with probability 1, have a derivative at no time, so \(dS/dt\) does not exist. For such a path the change of \(V\) over a short time also has a second-order term in the price change; that is Itô's lemma. The smooth path in P4 is a simplification for practice with the chain rule.
Related: Dot product and orthogonal projection, for the vector form of the rule, and Itô's lemma, for paths without a derivative.
Further reading
- J. Stewart, Calculus: Early Transcendentals, 8th ed. (Cengage, 2016), section 14.5, “The Chain Rule.”
- J. E. Marsden and A. Tromba, Vector Calculus, 6th ed. (W. H. Freeman, 2012), chapter 2, “Differentiation,” on the chain rule for functions of several variables.
- S. E. Shreve, Stochastic Calculus for Finance II: Continuous-Time Models (Springer, 2004), chapter 4, “Stochastic Calculus,” on the Itô–Doeblin formula.