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
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 holds at that point as well.
Since \(\displaystyle f\) is differentiable at \(\displaystyle P\), we know that
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
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 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:
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\]
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\):
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.
Figure \(\PageIndex{1}\): Tree diagram for the case \(\displaystyle \dfrac{dz}{dt}=\dfrac{∂z}{∂x}⋅\dfrac{dx}{dt}+\dfrac{∂z}{∂y}⋅\dfrac{dy}{dt}.\)
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
We can draw a tree diagram for each of these formulas as well as follows.
Figure \(\PageIndex{2}\): Tree diagram for \(\displaystyle \dfrac{∂z}{∂u}=\dfrac{∂z}{∂x}⋅\dfrac{∂x}{∂u}+\dfrac{∂z}{∂y}⋅\dfrac{∂y}{∂u}\) and \(\displaystyle \dfrac{∂z}{∂v}=\dfrac{∂z}{∂x}⋅\dfrac{∂x}{∂v}+\dfrac{∂z}{∂y}⋅\dfrac{∂y}{∂v}\).
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:
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\):
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
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 \\ x&=x(u,v)=e^u\sin v \\ y&=y(u,v)=e^u\cos v \\ z&=z(u,v)=e^u. \end{align*}\]
Solution
The formulas for \(\displaystyle ∂w/∂u\) and \(\displaystyle ∂w/∂v\) are
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\).
Figure \(\PageIndex{3}\): Tree diagram for a function of three variables, each of which is a function of three independent variables.
Recall fromimplicit 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.
Figure \(\PageIndex{4}\): Graph of the ellipse defined by \(\displaystyle x^2+3y^2+4y−4=0\).
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:
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}\]
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
Equation is a direct consequence of Equation. 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:\)
Solving this equation for \(\displaystyle dy/dx\) gives Equation. Equation 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
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.\)
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.
Solution
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.
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.