Ma · Mathematics

How to Use the Chain Rule in Multivariable Calculus

Published By the 9to5Science editorial team

At a glance

  1. 1. Identify the composition

    Write down which variables depend on which other variables.

  2. 2. Differentiate each link

    Find the relevant partial derivatives at each stage of the composition.

  3. 3. Multiply and add

    Multiply along each dependency path, then add the contributions.

  4. 4. Substitute the point

    Evaluate the derivatives at the corresponding input values.

The multivariable chain rule tells you how to differentiate a function whose inputs depend on other variables. The main idea is simple: follow every route by which a variable can affect the output, multiply the derivatives along that route, and add the results.

The basic formula

Suppose z=f(x,y)z=f(x,y), where both xx and yy are differentiable functions of a parameter tt, and ff is differentiable at the corresponding point. Then zz also depends on tt, and

dzdt=∂f∂xdxdt+∂f∂ydydt.\frac{dz}{dt}=\frac{\partial f}{\partial x}\frac{dx}{dt}+\frac{\partial f}{\partial y}\frac{dy}{dt}.

The partial derivatives of ff measure how zz changes when one input changes while the other is held fixed. The derivatives dx/dtdx/dt and dy/dtdy/dt describe how the inputs change with tt. Each product is one input’s contribution to the overall change in zz.

If ff is differentiable and each xi=xi(t)x_i=x_i(t) is differentiable, the same rule becomes

dzdt=∑i=1n∂f∂xidxidt.\frac{dz}{dt}=\sum_{i=1}^{n}\frac{\partial f}{\partial x_i}\frac{dx_i}{dt}.

A worked example with two parameters

Let

z=f(x,y)=x2+3xy,x=s+t,y=st.z=f(x,y)=x^2+3xy, \qquad x=s+t, \qquad y=st.

Find ∂z/∂s\partial z/\partial s and ∂z/∂t\partial z/\partial t. First differentiate the outer function:

fx=2x+3y,fy=3x.f_x=2x+3y, \qquad f_y=3x.

Then differentiate the inner functions:

xs=1,ys=t,xt=1,yt=s.x_s=1, \quad y_s=t, \qquad x_t=1, \quad y_t=s.

Apply the chain rule separately for each parameter:

∂z∂s=fxxs+fyys=fx+tfy,∂z∂t=fxxt+fyyt=fx+sfy.\frac{\partial z}{\partial s}=f_x x_s+f_y y_s=f_x+t f_y, \qquad \frac{\partial z}{\partial t}=f_x x_t+f_y y_t=f_x+s f_y.

To evaluate these at (s,t)=(1,2)(s,t)=(1,2), first find the corresponding outer inputs: x=1+2=3x=1+2=3 and y=1⋅2=2y=1\cdot2=2. Thus fx=2(3)+3(2)=12f_x=2(3)+3(2)=12 and fy=3(3)=9f_y=3(3)=9. Therefore,

∂z∂s∣(1,2)=12+2(9)=30,∂z∂t∣(1,2)=12+1(9)=21.\left.\frac{\partial z}{\partial s}\right|_{(1,2)}=12+2(9)=30, \qquad \left.\frac{\partial z}{\partial t}\right|_{(1,2)}=12+1(9)=21.

You can check by substitution: z=(s+t)2+3(s+t)stz=(s+t)^2+3(s+t)st. Differentiating this expression directly also gives zs=30z_s=30 and zt=21z_t=21 at (1,2)(1,2).

The same rule in Jacobian form

For differentiable functions with several outputs, use Jacobian matrices. If gg maps an input vector to an intermediate vector and ff maps that intermediate vector to an output, then

Jf∘g(u)=Jf(g(u))Jg(u).J_{f\circ g}(\mathbf{u})=J_f(g(\mathbf{u}))J_g(\mathbf{u}).

The order matters: the Jacobian of the outer function is evaluated at the output of the inner function, and it is multiplied on the left. This is the matrix version of multiplying derivatives along a dependency path and adding contributions that reach the same output.

For example, if g(s,t)=(x(s,t),y(s,t))g(s,t)=(x(s,t),y(s,t)) and f(x,y)f(x,y) is scalar-valued, then

Jg=[xsxtysyt],Jf=[fxfy].J_g= \begin{bmatrix} x_s & x_t\\ y_s & y_t \end{bmatrix}, \qquad J_f=\begin{bmatrix}f_x & f_y\end{bmatrix}.

Their product is Jf∘g=[zszt]J_{f\circ g}=\begin{bmatrix}z_s & z_t\end{bmatrix}, giving the two partial-derivative formulas above.

A quick way to organize the calculation

For a longer composition, sketch a dependency diagram. For example, if z=f(x,y)z=f(x,y) and x,yx,y depend on s,ts,t, draw arrows from ss and tt to the intermediate variables they affect, then arrows from x,yx,y to zz. To find zsz_s, follow only paths starting at ss. Multiply the derivatives on each path and add the path products. This is often easier to remember than trying to memorize a large formula.

If there is just one path, such as z=f(x)z=f(x) with x=x(t)x=x(t), the rule reduces to the familiar single-variable form dz/dt=f′(x)x′(t)dz/dt=f'(x)x'(t).

Common mistakes

  • Leaving out an indirect effect: If tt affects both xx and yy, both terms belong in dz/dtdz/dt.
  • Using ordinary derivatives for the wrong role: Use partial derivatives such as fxf_x for the outer function, and derivatives such as xtx_t for the inner functions.
  • Substituting too early: Keep the variables symbolic until you have formed the chain-rule expression. Then substitute the corresponding intermediate values.
  • Reversing Jacobian order: For f∘gf\circ g, the product is Jf(g(u))Jg(u)J_f(g(\mathbf{u}))J_g(\mathbf{u}), not the reverse.
  • Confusing partial and total change: A partial derivative of ff holds its other input fixed. The derivative of a composition includes all changing inputs through the chain rule.

References

  1. Calculus: Early Transcendentals, James Stewart

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.