# 3.10: The Chain Rule for Functions of Multiple Variables

- Last updated

- Save as PDF

- Page ID
- 20222

\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

In single-variable calculus, we found that one of the most useful differentiation rules is the chain rule, which allows us to find the derivative of the composition of two functions. The same thing is true for multivariable calculus, but this time we have to deal with more than one form of the chain rule. In this section, we study extensions of the chain rule and learn how to take derivatives of compositions of functions of more than one variable.

## Chain Rules for One or Two Independent Variables

Recall that the chain rule for the derivative of a composite of two functions can be written in the form

\[\dfrac{d}{dx}(f(g(x)))=f′(g(x))g′(x).\]

In this equation, both \(\displaystyle f(x)\) and \(\displaystyle g(x)\) are functions of one variable. Now suppose that \(\displaystyle f\) is a function of two variables and \(\displaystyle g\) is a function of one variable. Or perhaps they are both functions of two variables, or even more. How would we calculate the derivative in these cases? The following theorem gives us the answer for the case of one independent variable.

Chain Rule for One Independent Variable

Suppose that \(\displaystyle x=g(t)\) and \(\displaystyle y=h(t)\) are differentiable functions of \(\displaystyle t\) and \(\displaystyle z=f(x,y)\) is a differentiable function of \(\displaystyle x\) and \(\displaystyle y\). Then \(\displaystyle z=f(x(t),y(t))\) is a differentiable function of \(\displaystyle t\) and

\[\dfrac{dz}{dt}=\dfrac{∂z}{∂x}⋅\dfrac{dx}{dt}+\dfrac{∂z}{∂y}⋅\dfrac{dy}{dt}, \label{chain1}\]

where the ordinary derivatives are evaluated at \(\displaystyle t\) and the partial derivatives are evaluated at \(\displaystyle (x,y)\).

Proof

The proof of this theorem uses the definition of differentiability of a function of two variables. Suppose that *f* is differentiable at the point \(\displaystyle P(x_0,y_0),\) where \(\displaystyle x_0=g(t_0)\) and \(\displaystyle y_0=h(t_0)\) for a fixed value of \(\displaystyle t_0\). We wish to prove that \(\displaystyle z=f(x(t),y(t))\) is differentiable at \(\displaystyle t=t_0\) and that Equation \ref{chain1} holds at that point as well.

Since \(\displaystyle f\) is differentiable at \(\displaystyle P\), we know that

\[z(t)=f(x,y)=f(x_0,y_0)+f_x(x_0,y_0)(x−x_0)+f_y(x_0,y_0)(y−y_0)+E(x,y), \nonumber\]

where

\[ \lim_{(x,y)→(x_0,y_0)}\dfrac{E(x,y)}{\sqrt{(x−x_0)^2+(y−y_0)^2}}=0. \nonumber\]

We then subtract \(\displaystyle z_0=f(x_0,y_0)\) from both sides of this equation:

\[ \begin{align*} z(t)−z(t_0)&=f(x(t),y(t))−f(x(t_0),y(t_0)) \\[4pt] &=f_x(x_0,y_0)(x(t)−x(t_0))+f_y(x_0,y_0)(y(t)−y(t_0))+E(x(t),y(t)). \end{align*}\]

Next, we divide both sides by \(\displaystyle t−t_0\):

\[z(t)−z(t_0)t−t_0=fx(x_0,y_0)(x(t)−x(t_0)t−t_0)+f_y(x_0,y_0)(y(t)−y(t_0)t−t_0)+E(x(t),y(t))t−t_0. \nonumber\]

Then we take the limit as \(\displaystyle t\) approaches \(\displaystyle t_0\):

\[\begin{align*} \lim_{t→t_0}\dfrac{z(t)−z(t_0)}{t−t_0} = &f_x(x_0,y_0)\lim_{t→t_0} \left (\dfrac{x(t)−x(t_0)}{t−t_0} \right) \\[4pt]&+f_y(x_0,y_0)\lim_{t→t_0}\left (\dfrac{y(t)−y(t_0)}{t−t_0}\right)\\[4pt]&+\lim_{t→t_0}\dfrac{E(x(t),y(t))}{t−t_0}. \end{align*}\]

The left-hand side of this equation is equal to \(\displaystyle dz/dt\), which leads to

\[\dfrac{dz}{dt}=f_x(x_0,y_0)\dfrac{dx}{dt}+f_y(x_0,y_0)\dfrac{dy}{dt}+\lim_{t→t_0}\dfrac{E(x(t),y(t))}{t−t_0}. \nonumber\]

The last term can be rewritten as

\[\begin{align*} \lim_{t→t_0}\dfrac{E(x(t),y(t))}{t−t_0}&=\lim_{t→t_0}\dfrac{(E(x,y)}{\sqrt{(x−x_0)^2+(y−y_0)^2}}\dfrac{\sqrt{(x−x_0)^2+(y−y_0)^2}}{t−t_0}) \\[4pt] &=\lim_{t→t_0}\left(\dfrac{E(x,y)}{\sqrt{(x−x_0)^2+(y−y_0)^2}}\right)\lim_{t→t_0}\left(\dfrac{\sqrt{(x−x_0)^2+(y−y_0)^2}}{t−t_0}\right). \end{align*} \]

As \(\displaystyle t\) approaches \(\displaystyle t_0, (x(t),y(t))\) approaches \(\displaystyle (x(t_0),y(t_0)),\) so we can rewrite the last product as

\[\displaystyle \lim_{(x,y)→(x_0,y_0)}\dfrac{(E(x,y)}{\sqrt{(x−x_0)^2+(y−y_0)^2}}\lim_{(x,y)→(x_0,y_0)}(\dfrac{\sqrt{(x−x_0)^2+(y−y_0)^2}}{t−t_0}). \nonumber\]

Since the first limit is equal to zero, we need only show that the second limit is finite:

\[ \begin{align*} \lim_{(x,y)→(x_0,y_0)} \dfrac{\sqrt{ (x−x_0)^2+(y−y_0)^2 }} {t−t+0} &=\lim_{(x,y)→(x_0,y_0)} \sqrt{ \dfrac { (x−x_0)^2+(y−y_0)^2 } {(t−t_0)^2} } \\[4pt] &=\lim_{(x,y)→(x_0,y_0)}\sqrt{ \left(\dfrac{x−x_0}{t−t_0}\right)^2+\left(\dfrac{y−y_0}{t−t_0}\right)^2} \\[4pt] &=\sqrt{ \left[\lim_{(x,y)→(x_0,y_0)} \left(\dfrac{x−x_0}{t−t_0}\right)\right]^2+\left[\lim_{(x,y)→(x_0,y_0)} \left(\dfrac{y−y_0}{t−t_0}\right)\right]^2}. \end{align*} \]

Since \(\displaystyle x(t)\) and \(\displaystyle y(t)\) are both differentiable functions of \(\displaystyle t\), both limits inside the last radical exist. Therefore, this value is finite. This proves the chain rule at \(\displaystyle t=t_0\); the rest of the theorem follows from the assumption that all functions are differentiable over their entire domains.

□

Closer examination of Equation \ref{chain1} reveals an interesting pattern. The first term in the equation is \(\displaystyle \dfrac{∂f}{∂x} \cdot \dfrac{dx}{dt}\) and the second term is \(\displaystyle \dfrac{∂f}{∂y}⋅\dfrac{dy}{dt}\). Recall that when multiplying fractions, cancelation can be used. If we treat these derivatives as fractions, then each product “simplifies” to something resembling \(\displaystyle ∂f/dt\). The variables \(\displaystyle x\) and \(\displaystyle y\) that disappear in this simplification are often called **intermediate variables**: they are independent variables for the function \(\displaystyle f\), but are dependent variables for the variable \(\displaystyle t\). Two terms appear on the right-hand side of the formula, and \(\displaystyle f\) is a function of two variables. This pattern works with functions of more than two variables as well, as we see later in this section.

Example \(\PageIndex{1}\): Using the Chain Rule

Calculate \(\displaystyle dz/dt\) for each of the following functions:

- \(\displaystyle z=f(x,y)=4x^2+3y^2,x=x(t)=\sin t,y=y(t)=\cos t\)
- \(\displaystyle z=f(x,y)=\sqrt{x^2−y^2},x=x(t)=e^{2t},y=y(t)=e^{−t}\)

**Solution**

a. To use the chain rule, we need four quantities—\(\displaystyle ∂z/∂x,∂z/∂y,dx/dt\), and \(\displaystyle dy/dt\):

- \(\displaystyle \dfrac{∂z}{∂x}=8x\)
- \(\displaystyle \dfrac{dx}{dt}=\cos t\)
- \(\displaystyle \dfrac{∂z}{∂y}=6y\)
- \(\displaystyle \dfrac{dy}{dt}=−\sin t\)

Now, we substitute each of these into Equation \ref{chain1}:

\[\dfrac{dz}{dt}=\dfrac{\partial z}{\partial x} \cdot \dfrac{dx}{dt}+\dfrac{\partial z}{\partial y} \cdot \dfrac{dy}{dt}=(8x)(\cos t)+(6y)(−\sin t)=8x\cos t−6y\sin t. \nonumber\]

This answer has three variables in it. To reduce it to one variable, use the fact that \(\displaystyle x(t)=\sin t\) and \(y(t)=\cos t.\) We obtain

\[\displaystyle \dfrac{dz}{dt}=8x\cos t−6y\sin t=8(\sin t)\cos t−6(\cos t)\sin t=2\sin t\cos t. \nonumber\]

This derivative can also be calculated by first substituting \(\displaystyle x(t)\) and \(\displaystyle y(t)\) into \(\displaystyle f(x,y),\) then differentiating with respect to \(\displaystyle t\):

\[\displaystyle z=f(x,y)=f(x(t),y(t))=4(x(t))^2+3(y(t))^2=4\sin^2 t+3\cos^2 t. \nonumber\]

Then

\[\displaystyle \dfrac{dz}{dt}=2(4\sin t)(\cos t)+2(3\cos t)(−\sin t)=8\sin t\cos t−6\sin t\cos t=2\sin t\cos t, \nonumber\]

which is the same solution. However, it may not always be this easy to differentiate in this form.

b. To use the chain rule, we again need four quantities—\(\displaystyle ∂z/∂x,∂z/dy,dx/dt,\) and \(\displaystyle dy/dt:\)

- \(\displaystyle \dfrac{∂z}{∂x}=\dfrac{x}{\sqrt{x^2−y^2}}\)
- \(\displaystyle \dfrac{dx}{dt}=2e^{2t}\)
- \(\displaystyle \dfrac{∂z}{∂y}=\dfrac{−y}{\sqrt{x^2−y^2}}\)
- \(\displaystyle \dfrac{dx}{dt}=−e^{−t}.\)

We substitute each of these into Equation \ref{chain1}:

\[\begin{align*} \dfrac{dz}{dt}&=\dfrac{ \partial z}{ \partial x} \cdot \dfrac{dx}{dt}+\dfrac{ \partial z}{ \partial y}\cdot \dfrac{dy}{dt} \\[4pt] &=\left(\dfrac{x}{\sqrt{x^2−y^2}}\right) (2e^{2t})+\left(\dfrac{−y}{\sqrt{x^2−y^2}} \right) (−e^{−t}) \\[4pt] &=\dfrac{2xe^{2t}−ye^{−t}}{\sqrt{x^2−y^2}}. \end{align*} \]

To reduce this to one variable, we use the fact that \(\displaystyle x(t)=e^{2t}\) and \(\displaystyle y(t)=e^{−t}\). Therefore,

\[ \begin{align*} \dfrac{dz}{dt}&=\dfrac{2xe^2t+ye^{−t}}{\sqrt{x^2−y^2}} \\[4pt] &=\dfrac{2(e^{2t})e^{2t}+(e^{−t})e^{−t}}{\sqrt{e^{4t}−e^{−2t}}} \\[4pt] &=\dfrac{2e^{4t}+e^{−2t}}{\sqrt{e^{4t}−e^{−2t}}}. \end{align*} \]

To eliminate negative exponents, we multiply the top by \(\displaystyle e^{2t}\) and the bottom by \(\displaystyle \sqrt{e^{4t}}\):

\[\begin{align*} \dfrac{dz}{dt}&=\dfrac{2e^{4t}+e^{−2t}}{\sqrt{e^{4t}−e^{−2t}}}⋅\dfrac{e^{2t}}{\sqrt{e^{4t}}} \\[4pt] &=\dfrac{2e^{6t}+1}{\sqrt{e^{8t}−e^{2t}}} \\[4pt] & =\dfrac{2e^{6t}+1}{\sqrt{e^{2t}(e^{6t}−1)}} \\[4pt] & =\dfrac{2e^{6t}+1}{e^t\sqrt{e^{6t}−1}}. \end{align*}\]

Again, this derivative can also be calculated by first substituting \(\displaystyle x(t)\) and \(\displaystyle y(t)\) into \(\displaystyle f(x,y),\) then differentiating with respect to \(\displaystyle t\):

\[\begin{align*} z&=f(x,y) \\[4pt] &=f(x(t),y(t)) \\[4pt] &=\sqrt{(x(t))^2−(y(t))^2} \\[4pt]&=\sqrt{e^{4t}−e^{−2t}} \\[4pt] &=(e^{4t}−e^{−2t})^{1/2}. \end{align*} \]

Then

\[ \begin{align*} \dfrac{dz}{dt} &= \dfrac{1}{2} (e^{4t}−e^{−2t})^{−1/2} \left(4e^{4t}+2e^{−2t} \right) \\[4pt] &=\dfrac{2e^{4t}+e^{−2t}}{\sqrt{e^{4t}−e^{−2t}}}. \end{align*}\]

This is the same solution.

Exercise \(\PageIndex{1}\)

Calculate \(dz/dt \) given the following functions. Express the final answer in terms of \(\displaystyle t\).

\[ \begin{align*} z&=f(x,y)=x^2−3xy+2y^2 \\[4pt] x &=x(t)=3\sin2t,y=y(t)=4\cos 2t \end{align*}\]

**Hint**-
Calculate \(\displaystyle ∂z/∂x,∂z/dy,dx/dt,\) and \(\displaystyle dy/dt\), then use Equation \ref{chain1}.

**Answer:**-
\(\displaystyle \dfrac{dz}{dt}=\dfrac{∂f}{∂x}\dfrac{dx}{dt}+\dfrac{∂f}{∂y}\dfrac{dy}{dt}\)

\(\displaystyle =(2x−3y)(6\cos2t)+(−3x+4y)(−8\sin2t)\)

\(\displaystyle =−92\sin 2t \cos 2t−72(\cos ^22t−\sin^22t)\)

\(\displaystyle =−46\sin 4t−72\cos 4t.\)

It is often useful to create a visual representation of Equation for the chain rule. This is called a **tree diagram** for the chain rule for functions of one variable and it provides a way to remember the formula (Figure \(\PageIndex{1}\)). This diagram can be expanded for functions of more than one variable, as we shall see very shortly.

In this diagram, the leftmost corner corresponds to \(\displaystyle z=f(x,y)\). Since \(\displaystyle f\) has two** independent variables**, there are two lines coming from this corner. The upper branch corresponds to the variable \(\displaystyle x\) and the lower branch corresponds to the variable \(\displaystyle y\). Since each of these variables is then dependent on one variable \(\displaystyle t\), one branch then comes from \(\displaystyle x\) and one branch comes from \(\displaystyle y\). Last, each of the branches on the far right has a label that represents the path traveled to reach that branch. The top branch is reached by following the \(\displaystyle x\) branch, then the t branch; therefore, it is labeled \(\displaystyle (∂z/∂x)×(dx/dt).\) The bottom branch is similar: first the \(\displaystyle y\) branch, then the \(\displaystyle t\) branch. This branch is labeled \(\displaystyle (∂z/∂y)×(dy/dt)\). To get the formula for \(\displaystyle dz/dt,\) add all the terms that appear on the rightmost side of the diagram. This gives us Equation.

In Note, \(\displaystyle z=f(x,y)\) is a function of \(\displaystyle x\) and \(\displaystyle y\), and both \(\displaystyle x=g(u,v)\) and \(\displaystyle y=h(u,v)\) are functions of the independent variables \(\displaystyle u\) and \(\displaystyle v\).

Chain Rule for Two Independent Variables

Suppose \(\displaystyle x=g(u,v)\) and \(\displaystyle y=h(u,v)\) are differentiable functions of \(\displaystyle u\) and \(\displaystyle v\), and \(\displaystyle z=f(x,y)\) is a differentiable function of \(\displaystyle x\) and \(\displaystyle y\). Then, \(\displaystyle z=f(g(u,v),h(u,v))\) is a differentiable function of \(\displaystyle u\) and \(\displaystyle v\), and

\[\dfrac{∂z}{∂u}=\dfrac{∂z}{∂x}\dfrac{∂x}{∂u}+\dfrac{∂z}{∂y}\dfrac{∂y}{∂u} \label{chain2a}\]

and

\[\dfrac{∂z}{∂v}=\dfrac{∂z}{∂x}\dfrac{∂x}{∂v}+\dfrac{∂z}{∂y}\dfrac{∂y}{∂v}. \label{chian2b}\]

We can draw a tree diagram for each of these formulas as well as follows.

To derive the formula for \(\displaystyle ∂z/∂u\), start from the left side of the diagram, then follow only the branches that end with \(\displaystyle u\) and add the terms that appear at the end of those branches. For the formula for \(\displaystyle ∂z/∂v\), follow only the branches that end with \(\displaystyle v\) and add the terms that appear at the end of those branches.

There is an important difference between these two chain rule theorems. In Note, the left-hand side of the formula for the derivative is not a partial derivative, but in Note it is. The reason is that, in Note, \(\displaystyle z\) is ultimately a function of \(\displaystyle t\) alone, whereas in Note, \(\displaystyle z\) is a function of both \(\displaystyle u\) and \(\displaystyle v\).

Example \(\PageIndex{2}\): Using the Chain Rule for Two Variables

Calculate \(\displaystyle ∂z/∂u\) and \(\displaystyle ∂z/∂v\) using the following functions:

\[\displaystyle z=f(x,y)=3x^2−2xy+y^2,\; x=x(u,v)=3u+2v,\; y=y(u,v)=4u−v. \nonumber\]

**Solution**

To implement the chain rule for two variables, we need six partial derivatives—\(\displaystyle ∂z/∂x,\; ∂z/∂y,\; ∂x/∂u,\; ∂x/∂v,\; ∂y/∂u,\) and \(\displaystyle ∂y/∂v\):

\[\begin{align*} \dfrac{∂z}{∂x}&=6x−2y && \dfrac{∂z}{∂y}=−2x+2y \\[4pt] \displaystyle \dfrac{∂x}{∂u}&=3 && \dfrac{∂x}{∂v}=2 \\[4pt] \dfrac{∂y}{∂u}&=4 && \dfrac{∂y}{∂v}=−1. \end{align*}\]

To find \(\displaystyle ∂z/∂u,\) we use Equation \ref{chain2a}:

\[\begin{align*} \dfrac{∂z}{∂u}&=\dfrac{∂z}{∂x}⋅\dfrac{∂x}{∂u}+\dfrac{∂z}{∂y}⋅\dfrac{∂y}{∂u} \\[4pt] &=3(6x−2y)+4(−2x+2y) \\[4pt] &=10x+2y. \end{align*}\]

Next, we substitute \(\displaystyle x(u,v)=3u+2v\) and \(\displaystyle y(u,v)=4u−v:\)

\[\begin{align*} \dfrac{∂z}{∂u}&=10x+2y \\[4pt] &=10(3u+2v)+2(4u−v) \\[4pt] &=38u+18v. \end{align*}\]

To find \(\displaystyle ∂z/∂v,\) we use Equation \ref{chain2b}:

\[\begin{align*} \dfrac{∂z}{∂v}&=\dfrac{∂z}{∂x}\dfrac{∂x}{∂v}+\dfrac{∂z}{∂y}\dfrac{∂y}{∂v} \\[4pt] &=2(6x−2y)+(−1)(−2x+2y) \\[4pt] &=14x−6y. \end{align*}\]

Then we substitute \(\displaystyle x(u,v)=3u+2v\) and \(\displaystyle y(u,v)=4u−v:\)

\[\begin{align*} \dfrac{∂z}{∂v}&=14x−6y \\[4pt] &=14(3u+2v)−6(4u−v) \\[4pt] &=18u+34v \end{align*}\]

Exercise \(\PageIndex{2}\)

Calculate \(\displaystyle ∂z/∂u\) and \(\displaystyle ∂z/∂v\) given the following functions:

\[ z=f(x,y)=\dfrac{2x−y}{x+3y},\; x(u,v)=e^{2u}\cos 3v,\; y(u,v)=e^{2u}\sin 3v. \nonumber\]

**Hint**-
Calculate \(\displaystyle ∂z/∂x,\; ∂z/∂y,\; ∂x/∂u,\; ∂x/∂v,\; ∂y/∂u,\) and \(\displaystyle ∂y/∂v\), then use Equation \ref{chain2a} and Equation \ref{chain2b}.

**Answer**-
\(\displaystyle \dfrac{∂z}{∂u}=0,\dfrac{∂z}{∂v}=\dfrac{−21}{(3\sin 3v+\cos 3v)^2}\)

## The Generalized Chain Rule

Now that we’ve see how to extend the original chain rule to functions of two variables, it is natural to ask: Can we extend the rule to more than two variables? The answer is yes, as the *generalized chain rule *states.

Generalized Chain Rule

Let \(\displaystyle w=f(x_1,x_2,…,x_m)\) be a differentiable function of \(\displaystyle m\) independent variables, and for each \(\displaystyle i∈{1,…,m},\) let \(\displaystyle x_i=x_i(t_1,t_2,…,t_n)\) be a differentiable function of \(\displaystyle n\) independent variables. Then

\[\dfrac{∂w}{∂t_j}=\dfrac{∂w}{∂x_1}\dfrac{∂x_1}{∂t_j}+\dfrac{∂w}{∂x_2}\dfrac{∂x_2}{∂t_j}+⋯+\dfrac{∂w}{∂x_m}\dfrac{∂x_m}{∂t_j}\]

for any \(\displaystyle j∈{1,2,…,n}.\)

In the next example we calculate the derivative of a function of three independent variables in which each of the three variables is dependent on two other variables.

Example \(\PageIndex{3}\): Using the Generalized Chain Rule

Calculate \(\displaystyle ∂w/∂u\) and \(\displaystyle ∂w/∂v\) using the following functions:

\[\begin{align*} w&=f(x,y,z)=3x^2−2xy+4z^2 \\[4pt] x&=x(u,v)=e^u\sin v \\[4pt] y&=y(u,v)=e^u\cos v \\[4pt] z&=z(u,v)=e^u. \end{align*}\]

**Solution**

The formulas for \(\displaystyle ∂w/∂u\) and \(\displaystyle ∂w/∂v\) are

\[\begin{align*} \dfrac{∂w}{∂u}&=\dfrac{∂w}{∂x}⋅\dfrac{∂x}{∂u}+\dfrac{∂w}{∂y}⋅\dfrac{∂y}{∂u}+\dfrac{∂w}{∂z}⋅\dfrac{∂z}{∂u} \\[4pt] \dfrac{∂w}{∂v}&=\dfrac{∂w}{∂x}⋅\dfrac{∂x}{∂v}+\dfrac{∂w}{∂y}⋅\dfrac{∂y}{∂v}+\dfrac{∂w}{∂z}⋅\dfrac{∂z}{∂v}. \end{align*}\]

Therefore, there are nine different partial derivatives that need to be calculated and substituted. We need to calculate each of them:

\[\begin{align*} &\dfrac{∂w}{∂x}=6x−2y && \dfrac{∂w}{∂y}=−2x && \dfrac{∂w}{∂z}=8z \\[4pt] &\dfrac{∂x}{∂u}=e^u\sin v && \dfrac{∂y}{∂u}=e^u\cos v && \dfrac{∂z}{∂u}=e^u \\[4pt] &dfrac{∂x}{∂v}=e^u\cos v && \dfrac{∂y}{∂v}=−e^u\sin v && \dfrac{∂z}{∂v}=0. \end{align*}\]

Now, we substitute each of them into the first formula to calculate \(\displaystyle ∂w/∂u\):

\[\begin{align*} \dfrac{∂w}{∂u}&=\dfrac{∂w}{∂x}⋅\dfrac{∂x}{∂u}+\dfrac{∂w}{∂y}⋅\dfrac{∂y}{∂u}+\dfrac{∂w}{∂z}⋅\dfrac{∂z}{∂u} \\[4pt] &=(6x−2y)e^u\sin v−2xe^u\cos v+8ze^u, \end{align*}\]

then substitute \(\displaystyle x(u,v)=e^u \sin v,y(u,v)=e^u\cos v,\) and \(\displaystyle z(u,v)=e^u\) into this equation:

\[\begin{align*} \dfrac{∂w}{∂u}&=(6x−2y)e^u\sin v−2xe^u\cos v+8ze^u \\[4pt] &=(6e^u\sin v−2eu\cos v)e^u\sin v−2(e^u\sin v)e^u\cos v+8e^{2u} \\[4pt] &=6e^{2u}\sin^2 v−4e^{2u}\sin v\cos v+8e^{2u} \\[4pt]&=2e^{2u}(3\sin^2 v−2\sin v\cos v+4). \end{align*}\]

Next, we calculate \(\displaystyle ∂w/∂v\):

\[\begin{align*} \dfrac{∂w}{∂v}&=\dfrac{∂w}{∂x}⋅\dfrac{∂x}{∂v}+\dfrac{∂w}{∂y}⋅\dfrac{∂y}{∂v}+\dfrac{∂w}{∂z}⋅\dfrac{∂z}{∂v} \\[4pt]&=(6x−2y)e^u\cos v−2x(−e^u\sin v)+8z(0), \end{align*}\]

then we substitute \(\displaystyle x(u,v)=e^u\sin v,y(u,v)=e^u\cos v,\) and \(\displaystyle z(u,v)=e^u\) into this equation:

\[\begin{align*} \dfrac{∂w}{∂v}&=(6x−2y)e^u\cos v−2x(−e^u\sin v) \\[4pt] &=(6e^u \sin v−2e^u\cos v)e^u\cos v+2(e^u\sin v)(e^u\sin v) \\[4pt] &=2e^{2u}\sin^2 v+6e^{2u}\sin v\cos v−2e^{2u}\cos^2 v \\[4pt] &=2e^{2u}(\sin^2 v+\sin v\cos v−\cos^2 v). \end{align*}\]

Exercise \(\PageIndex{3}\)

Calculate \(\displaystyle ∂w/∂u\) and \(\displaystyle ∂w/∂v\) given the following functions:

\[\begin{align*} w&=f(x,y,z)=\dfrac{x+2y−4z}{2x−y+3z} \\[4pt] x&=x(u,v)=e^{2u}\cos3v \\[4pt] y&=y(u,v)=e^{2u}\sin 3v \\[4pt] z&=z(u,v)=e^{2u}. \end{align*}\]

**Hint**-
Calculate nine partial derivatives, then use the same formulas from Example \(\PageIndex{3}\).

**Answer**-
\(\displaystyle \dfrac{∂w}{∂u}=0\)

\(\displaystyle \dfrac{∂w}{∂v}=\dfrac{15−33\sin 3v+6\cos 3v}{(3+2\cos 3v−\sin 3v)^2}\)

Example \(\PageIndex{4}\): Drawing a Tree Diagram

Create a tree diagram for the case when

\[ w=f(x,y,z),x=x(t,u,v),y=y(t,u,v),z=z(t,u,v) \nonumber\]

and write out the formulas for the three partial derivatives of \(\displaystyle w\).

**Solution**

Starting from the left, the function \(\displaystyle f\) has three independent variables: \(\displaystyle x,y\), and \(\displaystyle z\). Therefore, three branches must be emanating from the first node. Each of these three branches also has three branches, for each of the variables \(\displaystyle t,u,\) and \(\displaystyle v\).

The three formulas are

\[\begin{align*} \dfrac{∂w}{∂t}&=\dfrac{∂w}{∂x}\dfrac{∂x}{∂t}+\dfrac{∂w}{∂y}\dfrac{∂y}{∂t}+\dfrac{∂w}{∂z}\dfrac{∂z}{∂t} \\[4pt] \dfrac{∂w}{∂u}&=\dfrac{∂w}{∂x}\dfrac{∂x}{∂u}+\dfrac{∂w}{∂y}\dfrac{∂y}{∂u}+\dfrac{∂w}{∂z}\dfrac{∂z}{∂u} \\[4pt] \dfrac{∂w}{∂v}&=\dfrac{∂w}{∂x}\dfrac{∂x}{∂v}+\dfrac{∂w}{∂y}\dfrac{∂y}{∂v}+\dfrac{∂w}{∂z}\dfrac{∂z}{∂v}. \end{align*}\]

Exercise \(\PageIndex{4}\)

Create a tree diagram for the case when

\[\displaystyle w=f(x,y),x=x(t,u,v),y=y(t,u,v) \nonumber\]

and write out the formulas for the three partial derivatives of \(\displaystyle w.\)

**Hint**-
Determine the number of branches that emanate from each node in the tree.

**Answer**-
\[\begin{align*}\dfrac{∂w}{∂t}&=\dfrac{∂w}{∂x}\dfrac{∂x}{∂t}+\dfrac{∂w}{∂y}\dfrac{∂y}{∂t} \\[4pt] \dfrac{∂w}{∂u}&=\dfrac{∂w}{∂x}\dfrac{∂x}{∂u}+\dfrac{∂w}{∂y}\dfrac{∂y}{∂u} \\[4pt] \dfrac{∂w}{∂v}&=\dfrac{∂w}{∂x}\dfrac{∂x}{∂v}+\dfrac{∂w}{∂y}\dfrac{∂y}{∂v} \end{align*}\]

## Implicit Differentiation

Recall from** **implicit differentiation provides a method for finding \(\displaystyle dy/dx\) when \(\displaystyle y\) is defined implicitly as a function of \(\displaystyle x\). The method involves differentiating both sides of the equation defining the function with respect to \(\displaystyle x\), then solving for \(\displaystyle dy/dx.\) Partial derivatives provide an alternative to this method.

Consider the ellipse defined by the equation \(\displaystyle x^2+3y^2+4y−4=0\) as follows.

This equation implicitly defines \(\displaystyle y\) as a function of \(\displaystyle x\). As such, we can find the derivative \(\displaystyle dy/dx\) using the method of implicit differentiation:

\[\begin{align*}\dfrac{d}{dx}(x^2+3y^2+4y−4)&=\dfrac{d}{dx}(0) \\[4pt] 2x+6y\dfrac{dy}{dx}+4\dfrac{dy}{dx}&=0 \\[4pt] (6y+4)\dfrac{dy}{dx}&=−2x\\[4pt] \dfrac{dy}{dx}&=−\dfrac{x}{3y+2}\end{align*}\]

We can also define a function \(\displaystyle z=f(x,y)\) by using the left-hand side of the equation defining the ellipse. Then \(\displaystyle f(x,y)=x^2+3y^2+4y−4.\) The ellipse \(\displaystyle x^2+3y^2+4y−4=0\) can then be described by the equation \(\displaystyle f(x,y)=0\). Using this function and the following theorem gives us an alternative approach to calculating \(\displaystyle dy/dx.\)

Theorem: Implicit Differentiation of a Function of Two or More Variables

Suppose the function \(\displaystyle z=f(x,y)\) defines \(\displaystyle y\) implicitly as a function \(\displaystyle y=g(x)\) of \(\displaystyle x\) via the equation \(\displaystyle f(x,y)=0.\) Then

\[\dfrac{dy}{dx}=−\dfrac{∂f/∂x}{∂f/∂y} \label{implicitdiff1}\]

provided \(\displaystyle f_y(x,y)≠0.\)

If the equation \(\displaystyle f(x,y,z)=0\) defines \(\displaystyle z\) implicitly as a differentiable function of \(\displaystyle x\) and \(\displaystyle y\), then

\[\dfrac{dz}{dx}=−\dfrac{∂f/∂x}{∂f/∂z} \;\text{and}\; \dfrac{dz}{dy}=−\dfrac{∂f/∂y}{∂f/∂z}\label{implicitdiff2}\]

as long as \(\displaystyle f_z(x,y,z)≠0.\)

Equation \ref{implicitdiff1} is a direct consequence of Equation \ref{chain2a}. In particular, if we assume that \(\displaystyle y\) is defined implicitly as a function of \(\displaystyle x\) via the equation \(\displaystyle f(x,y)=0\), we can apply the chain rule to find \(\displaystyle dy/dx:\)

\[\begin{align*} \dfrac{d}{dx}f(x,y)&=\dfrac{d}{dx}(0) \\[4pt] \dfrac{∂f}{∂x}⋅\dfrac{dx}{dx}+\dfrac{∂f}{∂y}⋅\dfrac{dy}{dx}&=0 \\[4pt]\dfrac{∂f}{∂x}+\dfrac{∂f}{∂y}⋅\dfrac{dy}{dx}&=0. \end{align*}\]

Solving this equation for \(\displaystyle dy/dx\) gives Equation \ref{implicitdiff1}. Equation \ref{implicitdiff1} can be derived in a similar fashion.

Let’s now return to the problem that we started before the previous theorem. Using Note and the function \(\displaystyle f(x,y)=x^2+3y^2+4y−4,\) we obtain

\[\begin{align*} \dfrac{∂f}{∂x}&=2x\\[4pt] \dfrac{∂f}{∂y}&=6y+4. \end{align*}\]

Then Equation \ref{implicitdiff1} gives

\[\dfrac{dy}{dx}=−\dfrac{∂f/∂x}{∂f/∂y}=−\dfrac{2x}{6y+4}=−\dfrac{x}{3y+2},\]

which is the same result obtained by the earlier use of implicit differentiation.

Example \(\displaystyle \PageIndex{5}\): Implicit Differentiation by Partial Derivatives

- Calculate \(\displaystyle dy/dx\) if y is defined implicitly as a function of \(\displaystyle x\) via the equation \(\displaystyle 3x^2−2xy+y^2+4x−6y−11=0\). What is the equation of the tangent line to the graph of this curve at point \(\displaystyle (2,1)\)?
- Calculate \(\displaystyle ∂z/∂x\) and \(\displaystyle ∂z/∂y,\) given \(\displaystyle x^2e^y−yze^x=0.\)

**Solution**

a. Set \(\displaystyle f(x,y)=3x^2−2xy+y^2+4x−6y−11=0,\) then calculate \(\displaystyle f_x\) and \(\displaystyle f_y: f_x=6x−2y+4\) \(\displaystyle f_y=−2x+2y−6.\)

The derivative is given by

\[\displaystyle \dfrac{dy}{dx}=−\dfrac{∂f/∂x}{∂f/∂y}=\dfrac{6x−2y+4}{−2x+2y−6}=\dfrac{3x−y+2}{x−y+3}. \nonumber\]

The slope of the tangent line at point \(\displaystyle (2,1)\) is given by

\[\displaystyle \dfrac{dy}{dx}∣_{(x,y)=(2,1)}=\dfrac{3(2)−1+2}{2−1+3}=\dfrac{7}{4} \nonumber\]

To find the equation of the tangent line, we use the point-slope form (Figure \(\PageIndex{5}\)):

\[\begin{align*} y−y_0&=m(x−x_0)\\[4pt]y−1&=\dfrac{7}{4}(x−2) \\[4pt] y&=\dfrac{7}{4}x−\dfrac{7}{2}+1\\[4pt] y&=\dfrac{7}{4}x−\dfrac{5}{2}.\end{align*}\]

b. We have \(\displaystyle f(x,y,z)=x^2e^y−yze^x.\) Therefore,

\[\begin{align*} \dfrac{∂f}{∂x}&=2xe^y−yze^x \\[4pt] \dfrac{∂f}{∂y}&=x^2e^y−ze^x \\[4pt] \dfrac{∂f}{∂z}&=−ye^x\end{align*}\]

Using Equation \ref{implicitdiff2},

\[\begin{align*} \dfrac{∂z}{∂x}&=−\dfrac{∂f/∂x}{∂f/∂y} && &\dfrac{∂z}{∂y}&=−\dfrac{∂f/∂y}{∂f/∂z} \\[4pt] &=−\dfrac{2xe^y−yze^x}{−ye^x} &\text{and}& &&=−\dfrac{x^2e^y−ze^x}{−ye^x} \\[4pt] &=\dfrac{2xe^y−yze^x}{ye^x} &&&& =\dfrac{x^2e^y−ze^x}{ye^x} \end{align*}\]

Exercise \(\PageIndex{5}\)

Find \(\displaystyle dy/dx\) if \(\displaystyle y\) is defined implicitly as a function of \(\displaystyle x\) by the equation \(\displaystyle x^2+xy−y^2+7x−3y−26=0\). What is the equation of the tangent line to the graph of this curve at point \(\displaystyle (3,−2)\)?

**Hint**-
Calculate \(\displaystyle ∂f/dx\) and \(\displaystyle ∂f/dy\), then use Equation \ref{implicitdiff1}.

**Solution**-
\[\dfrac { d y } { d x } = \left. \frac { 2 x + y + 7 } { 2 y - x + 3 } \right| _ { ( 3 , - 2 ) } = \dfrac { 2 ( 3 ) + ( - 2 ) + 7 } { 2 ( - 2 ) - ( 3 ) + 3 } = - \dfrac { 11 } { 4 } \nonumber\]

Equation of the tangent line: \(\displaystyle y=−\dfrac{11}{4}x+\dfrac{25}{4}\)

## Key Concepts

- The chain rule for functions of more than one variable involves the partial derivatives with respect to all the independent variables.
- Tree diagrams are useful for deriving formulas for the chain rule for functions of more than one variable, where each independent variable also depends on other variables.

## Key Equations

**Chain rule, one independent variable**

\(\displaystyle \dfrac{dz}{dt}=\dfrac{∂z}{∂x}⋅\dfrac{dx}{dt}+\dfrac{∂z}{∂y}⋅\dfrac{dy}{dt}\)

**Chain rule, two independent variables**

\(\displaystyle \dfrac{dz}{du}=\dfrac{∂z}{∂x}⋅\dfrac{∂x}{∂u}+\dfrac{∂z}{∂y}⋅\dfrac{∂y}{∂u}\dfrac{dz}{dv}=\dfrac{∂z}{∂x}⋅\dfrac{∂x}{∂v}+\dfrac{∂z}{∂y}⋅\dfrac{∂y}{∂v}\)

**Generalized chain rule**

\(\displaystyle \dfrac{∂w}{∂t_j}=\dfrac{∂w}{∂x_1}\dfrac{∂x_1}{∂t_j}+\dfrac{∂w}{∂x_2}\dfrac{∂x_1}{∂t_j}+⋯+\dfrac{∂w}{∂x_m}\dfrac{∂x_m}{∂t_j}\)

## Glossary

**generalized chain rule**- the chain rule extended to functions of more than one independent variable, in which each independent variable may depend on one or more other variables

**intermediate variable**- given a composition of functions (e.g., \(\displaystyle f(x(t),y(t)))\), the intermediate variables are the variables that are independent in the outer function but dependent on other variables as well; in the function \(\displaystyle f(x(t),y(t)),\) the variables \(\displaystyle x\) and \(\displaystyle y\) are examples of intermediate variables

**tree diagram**- illustrates and derives formulas for the generalized chain rule, in which each independent variable is accounted for

## Contributors

Gilbert Strang (MIT) and Edwin “Jed” Herman (Harvey Mudd) with many contributing authors. This content by OpenStax is licensed with a CC-BY-SA-NC 4.0 license. Download for free at http://cnx.org.