Skip to content

The multivariable chain rule, explained with a tree diagram

5 min read

Short answer

If z=f(x,y)z=f(x,y) and both xx and yy depend on tt, then dzdt=∂f∂xdxdt+∂f∂ydydt.\frac{dz}{dt}=\frac{\partial f}{\partial x}\frac{dx}{dt}+\frac{\partial f}{\partial y}\frac{dy}{dt}. Draw a tree from zz to tt, multiply the derivatives along each path, and add the paths.

Tree diagram for the multivariable chain rule: z depends on x and y, which depend on t∂f/∂x∂f/∂ydx/dtdy/dtzxyttdz/dt = f_x · x′ + f_y · y′
Tree diagram: z depends on x and y, which both depend on t. Each path from z to t contributes one product.

Why every path counts

Changing tt moves both xx and yy, and each of them changes zz. The total change in zz is the sum of the two effects: the effect through xx is fx⋅x′(t)f_x\cdot x'(t) and the effect through yy is fy⋅y′(t)f_y\cdot y'(t). That is the whole rule.

Two inner variables

If xx and yy depend on two variables s,ts,t, draw the same tree and use partial derivatives at the last step: ∂z∂s=fx∂x∂s+fy∂y∂s.\frac{\partial z}{\partial s}=f_x\frac{\partial x}{\partial s}+f_y\frac{\partial y}{\partial s}. The rule is always: one product per path from the top variable to the one you are differentiating by.

Worked example

Let z=x2yz=x^2y with x=cos⁡tx=\cos t and y=sin⁡ty=\sin t. Find dz/dtdz/dt and evaluate it at t=0t=0.

The partials are fx=2xyf_x=2xy and fy=x2f_y=x^2. The inner derivatives are x′=−sin⁡tx'=-\sin t and y′=cos⁡ty'=\cos t. Then dzdt=2xy(−sin⁡t)+x2cos⁡t=−2cos⁡tsin⁡2t+cos⁡3t.\frac{dz}{dt}=2xy(-\sin t)+x^2\cos t=-2\cos t\sin^2 t+\cos^3 t. At t=0t=0: cos⁡0=1\cos0=1, sin⁡0=0\sin0=0, so dzdt=0+1=1\dfrac{dz}{dt}=0+1=1.

Check by substituting first: z=cos⁡2tsin⁡tz=\cos^2t\sin t, so z′=−2cos⁡tsin⁡2t+cos⁡3tz'=-2\cos t\sin^2t+\cos^3t, the same ✓.

Try it yourself

Let z=xyz=xy with x=t2x=t^2 and y=ety=e^t. Find dz/dtdz/dt at t=1t=1.

Show the answer

dzdt=y⋅2t+x⋅et=2tet+t2et=et(2t+t2)\dfrac{dz}{dt}=y\cdot2t+x\cdot e^t=2te^t+t^2e^t=e^t(2t+t^2). At t=1t=1 this is 3e≈8.153e\approx8.15. (Direct check: z=t2etz=t^2e^t gives the same derivative.)

Keep going with practice

The chain rule for several variables is part of Vidi's Multivariable & Vector Calculus course, with step-by-step graded practice.