# Chain rule for multi-variable functions

So I have been studying the multi-variable chain rule. Most importantly, and this is what I must have overlooked, is it's not always clear to me how to see which variables are functions of other variables, so that you know when to use the chain rule. For example, if you have:
$$x^2+y^2-z^2+2xy=1$$ $$x^3+y^3-5y=8$$

In general, say we want to find $\frac{dz}{dt}$ but $z$ is a function of $x$, then we get:
$$\frac{dz}{dt} = \frac{dz}{dx} \frac{dx}{dt} .$$

And if $z$ is a function of both $y$ and $t$, we get:
$$\frac{dz}{dt} = \frac{dz}{dx} \frac{dx}{dt} + \frac{dz}{dy} \frac{dy}{dt}$$

In this case, we have two equations. One involving all three variables $x,y,z$ and one involving just $x,y$. Say we want to find $\frac{dz}{dx}$. What does this mean for this case? How should we interpret this rule in general?

-

You have

$\displaystyle x^2+y^2-z^2+2y=1$

$\displaystyle x^3+y^3-5y=8$

You can take the derivative of each with respect to $x$ to get

$\displaystyle 2x+2y\frac{dy}{dx}-2z\frac{dz}{dx}+2\frac{dy}{dx}=0$

$\displaystyle 3x^2+3y^2\frac{dy}{dx}-5\frac{dy}{dx}=0$

The second gives us $\frac{dy}{dx}=\frac{3x^2}{3y^2-5}$ which you can substitute into the first to find $\frac{dz}{dx}$

Response to edit of the question: The new first equation: $\displaystyle x^2+y^2-z^2+2xy=1$ when we take the derivative by x gives $\displaystyle 2x+2y\frac{dy}{dx}-2z\frac{dz}{dx}+2x\frac{dy}{dx}+2y=0$, which can still be solved for dz/dx given the dy/dx of the second equation.

-
Interesting. But how did you know to differentiate with respect to $x$, and why, in that case, do we have the derivative of $y^2$ times $\frac{dx}{dt}$? Why is y is a funtion of $x$ but not $z$? – fdart17 Feb 14 '11 at 3:40
You asked about dz/dx, so I started taking d/dx of things as that makes dz/dx appear. $t$ doesn't appear in the initial equations, and you mentioned it in the general discussion but not in the specific question, so it didn't seem to enter. I don't see the (derivative of y^2)*dx/dt, nor the derivative of (y^2*dx/dt) in my answer. You are right to ask about why $y$ is a function of $x$ but not $z$-I was regarding $x$ as the independent variable and $y,z$ as dependent, but that was not specified. You could change the derivatives to partials to take care of this. – Ross Millikan Feb 14 '11 at 3:51

If we have an explicit function $z = f(x_1,x_2,\ldots,x_n)$, then

$$\displaystyle \frac{dz}{dt} = \frac{\partial z}{\partial x_1} \frac{dx_1}{dt} + \frac{\partial z}{\partial x_2} \frac{dx_2}{dt} + \cdots +\frac{\partial z}{\partial x_n} \frac{dx_n}{dt}$$

If we have an implicit function $f(z,x_1,x_2,\ldots,x_n) = 0$, then

$$\displaystyle \frac{\partial f}{\partial z} \frac{dz}{dt} + \frac{\partial f}{\partial x_1} \frac{dx_1}{dt} + \frac{\partial f}{\partial x_2} \frac{dx_2}{dt} + \cdots +\frac{\partial f}{\partial x_n} \frac{dx_n}{dt} = 0$$

$$\displaystyle \frac{dz}{dt} = - \frac{ \frac{\partial f}{\partial x_1} \frac{dx_1}{dt} + \frac{\partial f}{\partial x_2} \frac{dx_2}{dt} + \cdots +\frac{\partial f}{\partial x_n} \frac{dx_n}{dt}}{\frac{\partial f}{\partial z} }$$

In the first example, \begin{align*} \displaystyle x^2 + y^2 - z^2 + 2y & = 1\\ \displaystyle 2x\frac{dx}{dt} + 2y\frac{dy}{dt} - 2z\frac{dz}{dt} + 2\frac{dy}{dt} & = 0\\ \displaystyle x\frac{dx}{dt} + y\frac{dy}{dt} + \frac{dy}{dt} & = z\frac{dz}{dt}\\ \displaystyle \frac{dz}{dt} & = \frac{x\frac{dx}{dt} + y\frac{dy}{dt} + \frac{dy}{dt}}{z} \end{align*}

In the second example, \begin{align*} \displaystyle x^3 + y^3 - 5y & = 8\\ \displaystyle 3x^2 \frac{dx}{dt} + 3y^2 \frac{dy}{dt} - 5 \frac{dy}{dt} = 0\\ \displaystyle \frac{dy}{dt} & = \frac{3x^2}{5-3y^2} \frac{dx}{dt} \end{align*}

-

What you want to look up is the chain rule for multivalued functions. What follows deals with the second example, where $z$ is a function of $x$ and $y$.

Suppose $z:\mathbb{R}^n\rightarrow \mathbb{R}$ and $\boldsymbol{T} : \mathbb{R} \rightarrow \mathbb{R}^n$ are two differentiable functions. Then $z\circ \boldsymbol{T} : \mathbb{R}\rightarrow \mathbb{R}$ and is differentiable, so we can ask what is $\frac {d(z(\boldsymbol{T}(t)))}{dt}$? It turns out that at $t=t_0$ we have $$\frac {d(z(\boldsymbol{T}(t)))}{dt} = \nabla z(\boldsymbol{T}(t_0))\cdot \boldsymbol{T}^'(t_0)$$ Where $\nabla$ is the gradient and the $\cdot$ refers to the dot product between vectors.

Hope that helps,

-