# 3.10: The Chain Rule for Functions of Multiple Variables

Learning Objectives

• State the chain rules for one or two independent variables.
• Use tree diagrams as an aid to understanding the chain rule for several independent and intermediate variables.
• Perform implicit differentiation of a function of two or more variables.

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 ef{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), onumber]

where

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

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

[ egin{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. onumber]

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

[egin{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} ight) [4pt] +f_y(x_0,y_0)lim_{t→t_0}left (dfrac{y(t)−y(t_0)}{t−t_0} ight)[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}. onumber]

The last term can be rewritten as

[egin{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}} ight)lim_{t→t_0}left(dfrac{sqrt{(x−x_0)^2+(y−y_0)^2}}{t−t_0} ight). 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}). onumber]

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

[ egin{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} ight)^2+left(dfrac{y−y_0}{t−t_0} ight)^2} [4pt] =sqrt{ left[lim_{(x,y)→(x_0,y_0)} left(dfrac{x−x_0}{t−t_0} ight) ight]^2+left[lim_{(x,y)→(x_0,y_0)} left(dfrac{y−y_0}{t−t_0} ight) ight]^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 ef{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:

1. (displaystyle z=f(x,y)=4x^2+3y^2,x=x(t)=sin t,y=y(t)=cos t)
2. (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 ef{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)=8xcos t−6ysin t. onumber]

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}=8xcos t−6ysin t=8(sin t)cos t−6(cos t)sin t=2sin tcos t. onumber]

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=4sin^2 t+3cos^2 t. onumber]

Then

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

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 ef{chain1}:

[egin{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}} ight) (2e^{2t})+left(dfrac{−y}{sqrt{x^2−y^2}} ight) (−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,

[ egin{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}}):

[egin{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^tsqrt{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):

[egin{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

[ egin{align*} dfrac{dz}{dt} = dfrac{1}{2} (e^{4t}−e^{−2t})^{−1/2} left(4e^{4t}+2e^{−2t} ight) [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).

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

Hint

Calculate (displaystyle ∂z/∂x,∂z/dy,dx/dt,) and (displaystyle dy/dt), then use Equation ef{chain1}.

(displaystyle dfrac{dz}{dt}=dfrac{∂f}{∂x}dfrac{dx}{dt}+dfrac{∂f}{∂y}dfrac{dy}{dt})

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

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

(displaystyle =−46sin 4t−72cos 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. onumber]

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):

[egin{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 ef{chain2a}:

[egin{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:)

[egin{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 ef{chain2b}:

[egin{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:)

[egin{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. onumber]

Hint

Calculate (displaystyle ∂z/∂x,; ∂z/∂y,; ∂x/∂u,; ∂x/∂v,; ∂y/∂u,) and (displaystyle ∂y/∂v), then use Equation ef{chain2a} and Equation ef{chain2b}.

(displaystyle dfrac{∂z}{∂u}=0,dfrac{∂z}{∂v}=dfrac{−21}{(3sin 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:

[egin{align*} w =f(x,y,z)=3x^2−2xy+4z^2 [4pt] x =x(u,v)=e^usin v [4pt] y =y(u,v)=e^ucos v [4pt] z =z(u,v)=e^u. end{align*}]

Solution

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

[egin{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:

[egin{align*} dfrac{∂w}{∂x}=6x−2y dfrac{∂w}{∂y}=−2x dfrac{∂w}{∂z}=8z [4pt] dfrac{∂x}{∂u}=e^usin v dfrac{∂y}{∂u}=e^ucos v dfrac{∂z}{∂u}=e^u [4pt] dfrac{∂x}{∂v}=e^ucos v dfrac{∂y}{∂v}=−e^usin v dfrac{∂z}{∂v}=0. end{align*}]

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

[egin{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^usin v−2xe^ucos v+8ze^u, end{align*}]

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

[egin{align*} dfrac{∂w}{∂u} =(6x−2y)e^usin v−2xe^ucos v+8ze^u [4pt] =(6e^usin v−2eucos v)e^usin v−2(e^usin v)e^ucos v+8e^{2u} [4pt] =6e^{2u}sin^2 v−4e^{2u}sin vcos v+8e^{2u} [4pt] =2e^{2u}(3sin^2 v−2sin vcos v+4). end{align*}]

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

[egin{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^ucos v−2x(−e^usin v)+8z(0), end{align*}]

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

[egin{align*} dfrac{∂w}{∂v} =(6x−2y)e^ucos v−2x(−e^usin v) [4pt] =(6e^u sin v−2e^ucos v)e^ucos v+2(e^usin v)(e^usin v) [4pt] =2e^{2u}sin^2 v+6e^{2u}sin vcos v−2e^{2u}cos^2 v [4pt] =2e^{2u}(sin^2 v+sin vcos v−cos^2 v). end{align*}]

Exercise (PageIndex{3})

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

[egin{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}).

(displaystyle dfrac{∂w}{∂u}=0)

(displaystyle dfrac{∂w}{∂v}=dfrac{15−33sin 3v+6cos 3v}{(3+2cos 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) onumber]

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

[egin{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) onumber]

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.

[egin{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:

[egin{align*}dfrac{d}{dx}(x^2+3y^2+4y−4) =dfrac{d}{dx}(0) [4pt] 2x+6ydfrac{dy}{dx}+4dfrac{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} ; ext{and}; dfrac{dz}{dy}=−dfrac{∂f/∂y}{∂f/∂z}label{implicitdiff2}]

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

Equation ef{implicitdiff1} is a direct consequence of Equation ef{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:)

[egin{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 ef{implicitdiff1}. Equation ef{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

[egin{align*} dfrac{∂f}{∂x} =2x[4pt] dfrac{∂f}{∂y} =6y+4. end{align*}]

Then Equation ef{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

1. 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))?
2. 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}. onumber]

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} onumber]

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

[egin{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,

[egin{align*} dfrac{∂f}{∂x} =2xe^y−yze^x [4pt] dfrac{∂f}{∂y} =x^2e^y−ze^x [4pt] dfrac{∂f}{∂z} =−ye^xend{align*}]

Using Equation ef{implicitdiff2},

[egin{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} ext{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 ef{implicitdiff1}.

Solution

[dfrac { d y } { d x } = left. frac { 2 x + y + 7 } { 2 y - x + 3 } ight| _ { ( 3 , - 2 ) } = dfrac { 2 ( 3 ) + ( - 2 ) + 7 } { 2 ( - 2 ) - ( 3 ) + 3 } = - dfrac { 11 } { 4 } onumber]

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