Tutorials › Calculus III › The Chain Rule with Several Intermediate Variables

Chain Rule and Implicit Differentiation · Tutorial 353 of 999

The Chain Rule with Several Intermediate Variables

Trace each dependency path and combine its contribution to compute partial derivatives of a composite function.

Intermediate 9 min read

What You'll Learn

  • State the chain rule for \(z=f(u,v)\), where \(u\) and \(v\) depend on \(x\) and \(y\)
  • Identify the derivatives contributed by each path from an independent variable to \(z\)
  • Evaluate outer and inner derivatives at the appropriate input values
  • Compute composite partial derivatives and check them by direct differentiation
  • Recognize when differentiability conditions are needed and avoid omitting a path

Introduction

A change in an independent variable can affect a final quantity through more than one intermediate variable. If \(z=f(u,v)\), and both \(u\) and \(v\) depend on \(x\) and \(y\), then changing \(x\) may change \(z\) through \(u\), through \(v\), or through both.

The chain rule accounts for all those routes. For each independent variable, it multiplies the derivative along each route and adds the results. The key is to track which variables depend on which others, then evaluate each derivative at the inputs where it belongs.

The Two-Intermediate-Variable Rule

Suppose \(u=u(x,y)\) and \(v=v(x,y)\), and define \(z=f(u,v)\). The composite function can be written as \(z=f(u(x,y),v(x,y))\). Provided the functions are differentiable at the relevant points, the partial derivatives of \(z\) are:

$$ \frac{\partial z}{\partial x} = \frac{\partial f}{\partial u}\frac{\partial u}{\partial x} + \frac{\partial f}{\partial v}\frac{\partial v}{\partial x}, \qquad \frac{\partial z}{\partial y} = \frac{\partial f}{\partial u}\frac{\partial u}{\partial y} + \frac{\partial f}{\partial v}\frac{\partial v}{\partial y}. $$

Here \(f_u\) and \(f_v\) are the partial derivatives of the outer function \(f\), with its inputs regarded as \(u\) and \(v\). They are evaluated at \((u(x,y),v(x,y))\). The derivatives \(u_x,u_y,v_x,v_y\) describe the intermediate variables' dependence on \(x\) and \(y\), and are evaluated at the relevant \((x,y)\).

Chain rule: The derivative with respect to an independent variable is the sum of the products along every path from that variable to the output. Thus \(z_x=f_u u_x+f_v v_x\), and \(z_y=f_u u_y+f_v v_y\).

For example, \(x\) affects \(z\) along the paths \(x\to u\to z\) and \(x\to v\to z\). The path through \(u\) contributes \(f_u u_x\); the path through \(v\) contributes \(f_v v_x\). Both contributions must be included, even if one of the intermediate variables appears less prominent in the formulas.

Why the Contributions Add

The rule follows from the first-order approximations for differentiable functions. Work at a fixed point \((x_0,y_0)\), and set \(u_0=u(x_0,y_0)\), \(v_0=v(x_0,y_0)\). For small changes \(h\) and \(k\), differentiability of \(u\) and \(v\) gives

$$ \begin{aligned} u(x_0+h,y_0+k)-u_0 &=u_xh+u_yk+o(r),\\ v(x_0+h,y_0+k)-v_0 &=v_xh+v_yk+o(r), \end{aligned} \qquad r=\sqrt{h^2+k^2}. $$

In these expressions, the derivatives on the right are evaluated at \((x_0,y_0)\). The notation \(o(r)\) means a remainder whose ratio to \(r\) tends to zero as \(r\) tends to zero. Let the two changes in the intermediate variables be \(\Delta u\) and \(\Delta v\). Since the displayed linear terms are bounded by a constant times \(r\), both \(\Delta u\) and \(\Delta v\) are \(O(r)\).

Differentiability of \(f\) at \((u_0,v_0)\) means that its change has the form

$$ \Delta z = f_u(u_0,v_0)\Delta u + f_v(u_0,v_0)\Delta v + o\!\left(\sqrt{(\Delta u)^2+(\Delta v)^2}\right). $$

Because \(\Delta u\) and \(\Delta v\) are \(O(r)\), the final remainder is \(o(r)\). Substituting their first-order expressions into the two linear terms therefore gives

$$ \Delta z = \bigl(f_u u_x+f_v v_x\bigr)h + \bigl(f_u u_y+f_v v_y\bigr)k + o(r), $$

where the outer derivatives are evaluated at \((u_0,v_0)\), and the inner derivatives at \((x_0,y_0)\). The coefficient of \(h\) is the partial derivative with respect to \(x\); the coefficient of \(k\) is the partial derivative with respect to \(y\). This proves the stated formulas. In particular, differentiability of the component functions at the points in question is a sufficient condition. Merely having partial derivatives at those points, without suitable differentiability, does not in general justify applying this rule.

Worked Examples

Worked Example: A Polynomial and Trigonometric Outer Function

Let \(z=f(u,v)=u^2v+\sin v\), where \(u=x+y^2\) and \(v=xy\). Find \(z_x\) and \(z_y\) at \((x,y)=(1,2)\).

First compute the intermediate values:

$$ u(1,2)=1+2^2=5, \qquad v(1,2)=1\cdot2=2. $$

The outer partial derivatives are

$$ f_u=2uv, \qquad f_v=u^2+\cos v. $$

At \((u,v)=(5,2)\), these become \(f_u=2\cdot5\cdot2=20\) and \(f_v=5^2+\cos2=25+\cos2\). The inner derivatives are \(u_x=1\), \(u_y=2y\), \(v_x=y\), and \(v_y=x\). At \((1,2)\), they are \(u_x=1\), \(u_y=4\), \(v_x=2\), and \(v_y=1\). Thus

$$ \begin{aligned} z_x(1,2) &=f_u u_x+f_v v_x\\ &=20\cdot1+(25+\cos2)\cdot2\\ &=70+2\cos2,\\[4pt] z_y(1,2) &=f_u u_y+f_v v_y\\ &=20\cdot4+(25+\cos2)\cdot1\\ &=105+\cos2. \end{aligned} $$

Check by substituting the intermediate variables first: \(z=(x+y^2)^2xy+\sin(xy)\). Direct partial differentiation gives

$$ \begin{aligned} z_x&=2(x+y^2)(1)xy+(x+y^2)^2y+y\cos(xy),\\ z_y&=2(x+y^2)(2y)xy+(x+y^2)^2x+x\cos(xy). \end{aligned} $$

At \((1,2)\), the first expression is \(2\cdot5\cdot1\cdot2+25\cdot2+2\cos2=70+2\cos2\). The second is \(2\cdot5\cdot4\cdot2+25+ \cos2=105+\cos2\), confirming both results.

Worked Example: An Exponential Composite

Let \(z=f(u,v)=e^{u+v}\), with \(u=x^2-y\) and \(v=xy^2\). Find \(z_x\) and \(z_y\) at \((1,1)\).

At that point, \(u=1^2-1=0\), \(v=1\cdot1^2=1\), so \(u+v=1\). The outer derivatives are \(f_u=e^{u+v}\) and \(f_v=e^{u+v}\), both equal to \(e\) at \((u,v)=(0,1)\). The inner derivatives are \(u_x=2x\), \(u_y=-1\), \(v_x=y^2\), and \(v_y=2xy\). At \((1,1)\), they have values \(2,-1,1,2\), respectively. Applying the rule gives

$$ \begin{aligned} z_x(1,1)&=e\cdot2+e\cdot1=3e,\\ z_y(1,1)&=e\cdot(-1)+e\cdot2=e. \end{aligned} $$

For a check, substitution gives \(z=e^{x^2-y+xy^2}\). Direct differentiation yields \(z_x=e^{x^2-y+xy^2}(2x+y^2)\) and \(z_y=e^{x^2-y+xy^2}(-1+2xy)\). At \((1,1)\), these are \(e(2+1)=3e\) and \(e(-1+2)=e\), as required.

Worked Example: A Quotient of Intermediate Variables

Let \(z=f(u,v)=u/v\), where \(u=x-y\) and \(v=x+y\). Find the partial derivatives at \((3,1)\). The rule applies near this point because \(v=3+1=4\ne0\), so the quotient is defined there.

The intermediate values are \(u=3-1=2\) and \(v=3+1=4\). The outer partial derivatives are \(f_u=1/v\) and \(f_v=-u/v^2\). At \((u,v)=(2,4)\), they are \(f_u=1/4\) and \(f_v=-2/16=-1/8\). The inner derivatives are \(u_x=1\), \(u_y=-1\), \(v_x=1\), and \(v_y=1\). Therefore

$$ \begin{aligned} z_x(3,1)&=\frac14\cdot1+\left(-\frac18\right)\cdot1=\frac18,\\ z_y(3,1)&=\frac14\cdot(-1)+\left(-\frac18\right)\cdot1=-\frac38. \end{aligned} $$

As a check, the composite is \(z=(x-y)/(x+y)\). Direct differentiation gives \(z_x=2y/(x+y)^2\) and \(z_y=-2x/(x+y)^2\). At \((3,1)\), these equal \(2/16=1/8\) and \(-6/16=-3/8\), agreeing with the chain-rule results.

A Common Mistake: Leaving Out a Path

A frequent error is to include only one of the intermediate variables when differentiating. For instance, in the first example, a mistaken calculation of \(z_x(1,2)\) might keep the route through \(u\) but omit the route through \(v\):

$$ \text{Incorrect:}\qquad z_x=f_u u_x=20\cdot1=20. $$

This is wrong because \(x\) changes \(v=xy\) as well as \(u=x+y^2\). The omitted contribution is \(f_vv_x=(25+\cos2)\cdot2\). Including both paths gives the correction:

$$ z_x=f_u u_x+f_vv_x =20\cdot1+(25+\cos2)\cdot2 =70+2\cos2. $$

A useful check is to list every intermediate variable that depends on the independent variable being differentiated. If both \(u\) and \(v\) depend on \(x\), both terms belong in \(z_x\). If one variable does not depend on \(x\), its corresponding term is zero.

Using the Rule Reliably

For a composite \(z=f(u(x,y),v(x,y))\), a consistent calculation proceeds in three stages:

1
Find the outer derivatives.
Compute \(f_u\) and \(f_v\), treating \(u\) and \(v\) as the inputs to \(f\).
2
Find the inner derivatives.
Compute \(u_x,u_y,v_x,v_y\) from the intermediate-variable formulas.
3
Combine matching paths.
Use \(z_x=f_u u_x+f_vv_x\) and \(z_y=f_u u_y+f_vv_y\), then evaluate at the requested inputs.

When evaluating at a particular point, keep the evaluation stages clear: first determine \(u\) and \(v\) there, then evaluate \(f_u\) and \(f_v\) at those intermediate values. The inner derivatives are evaluated at the original \((x,y)\). Mixing up those inputs is another avoidable source of errors.

The rule is useful whenever a quantity is built through intermediate variables: changing a coordinate can influence the output by several routes. Adding the contributions captures the total first-order effect of that coordinate change. The same reasoning applies separately to each independent variable, so the expressions for \(z_x\) and \(z_y\) differ in their inner derivatives but share the same outer derivatives at a given point.

Check Your Understanding

Use the chain rule for a function \(z=f(u,v)\) with \(u=u(x,y)\) and \(v=v(x,y)\). Keep track of all dependencies in each problem.

  1. Write the formulas for \(z_x\) and \(z_y\) in terms of the outer and inner partial derivatives.
  2. If \(u_x=0\) at a point but \(v_x\ne0\), what remains of the formula for \(z_x\) at that point?
  3. For \(z=u^2+v\), \(u=x+y\), and \(v=xy\), compute \(z_x\) and \(z_y\) at \((1,2)\).
  4. In the quotient example, why is it necessary to check that \(v\ne0\) before applying the rule?
  5. State the differentiability condition used in the derivation and explain why partial derivatives alone may not suffice.