# Rusty on Chain Rule

1. Sep 25, 2014

### hotvette

Not homework, just having fun. Every reference I find illustrates the chain rule for composite functions of two variables in this way:
\begin{align*} B &= f(x,y) \\ x &= g(w,z) \\ y &= h(w,z) \\ \frac{\partial B}{\partial w} &= \left( \frac{\partial B}{\partial x} \cdot \frac{\partial x}{\partial w} \right ) + \left(\frac{\partial B}{\partial y} \cdot \frac{\partial y}{\partial w}\right) \\ \frac{\partial B}{\partial z} &= \left(\frac{\partial B}{\partial x} \cdot \frac{\partial x}{\partial z}\right) + \left(\frac{\partial B}{\partial y} \cdot \frac{\partial y}{\partial z}\right) \end{align*}
But, my situation is:
\begin{align*} B &= f(x,y) \\ y &= g(x,z) \end{align*}
Is the following correct (since x is an independent variable)?
\begin{align*} \frac{\partial B}{\partial x} &= \left(\frac{\partial B}{\partial x} \cdot \frac{\partial x}{\partial x}\right) + \left(\frac{\partial B}{\partial y} \cdot \frac{\partial y}{\partial x}\right) \\ &= \left(\frac{\partial B}{\partial x} \cdot 1\right) + \left(\frac{\partial B}{\partial y} \cdot \frac{\partial y}{\partial x}\right) \\ &= \left(\frac{\partial B}{\partial x}\right) + \left(\frac{\partial B}{\partial y} \cdot \frac{\partial y}{\partial x}\right) \\ \\ \frac{\partial B}{\partial z} &= \left(\frac{\partial B}{\partial x} \cdot \frac{\partial x}{\partial z}\right) + \left(\frac{\partial B}{\partial y} \cdot \frac{\partial y}{\partial z}\right) \\ &= \left(\frac{\partial B}{\partial x} \cdot 0\right) + \left(\frac{\partial B}{\partial y} \cdot \frac{\partial y}{\partial z}\right) \\ &= \left(\frac{\partial B}{\partial y} \cdot \frac{\partial y}{\partial z}\right) \end{align*}
Looks kind of goofy, but seems to work using the following example:
\begin{align*} B &= x^2y + xy \\ y &= x^3z \end{align*}

Last edited: Sep 25, 2014
2. Sep 25, 2014

### Char. Limit

Looks right to me.

3. Sep 25, 2014

### SteamKing

Staff Emeritus
You've got a typo in the line above. In the first term to the right of the = sign, you should be taking
$\frac{\partial B}{\partial x} \cdot \frac{\partial x}{\partial w} + \frac{\partial B}{\partial y} \cdot \frac{\partial y}{\partial w}$

4. Sep 25, 2014

### Fredrik

Staff Emeritus
Be careful with the notation.
\begin{align}
&\frac{d}{dx}f(x,g(x,z)) =\lim_{h\to 0}\frac{f(x+h,g(x+h,z))-f(x,g(x,z))}{h}\\
&\frac{\partial}{\partial x}f(x,g(x,z)) =\lim_{h\to 0}\frac{f(x+h,g(x,z))-f(x,g(x,z))}{h}
\end{align} The former is the derivative of the function $t\mapsto f(t,g(t,z))$ at x. The latter is the derivative of the function $t\mapsto f(t,g(x,z))$ at x. The chain rule doesn't enter the picture when you evaluate the latter.

With this in mind, do you see what $\frac{d}{dz}f(x,g(x,z))$, $\frac{\partial}{\partial y}f(x,g(x,z))$ and $\frac{\partial}{\partial z}f(x,g(x,z))$ are? Answers below:

\begin{align}
&\frac{d}{dz}f(x,g(x,z)) =\lim_{h\to 0}\frac{f(x,g(x,z+h))-f(x,g(x,z))}{h}\\
&\frac{\partial}{\partial y}f(x,g(x,z)) =\lim_{h\to 0}\frac{f(x,g(x,z)+h)-f(x,g(x,z))}{h}\\
&\frac{\partial}{\partial z}f(x,g(x,z)) =\text{not defined}.
\end{align}

Last edited: Sep 25, 2014
5. Sep 25, 2014

### hotvette

Thanks, I fixed the typo and cleaned things up a bit.

Yep, I noticed something didn't quite look right about the notation $\left(\frac{\partial B}{\partial x} = \frac{\partial B}{\partial x} + \cdots\right)$,but I don't follow your post at all. Can you perhaps elaborate?

Last edited: Sep 25, 2014
6. Sep 26, 2014

### Fredrik

Staff Emeritus
Yes, but it would help if you first elaborate on what you find difficult to follow. Do you understand the definition of "derivative" for example?

7. Sep 26, 2014

### Fredrik

Staff Emeritus
My main point is that we take derivatives of functions, not of real numbers, and the notation we use at the start of the calculation should inform us what function we're differentiating.

The equations $B=x^2y+xy$ and $y=x^3z$ are constraints that tell us that the variables x,y,z,B (which all represent real numbers, not functions) must be assigned values that are consistent with the constraints. The constraints define a bunch of differentiable functions, and a notation like $\partial B/\partial x$ should refer to a partial derivative of one those functions. But what function, and what partial derivative?

Suppose that you define g by $g(r,s)=r^3s$ for all $r,s\in\mathbb R$, and f by $f(r,s)=r^2s+rs$ for all $r,s\in\mathbb R$. Then we have $B=f(x,g(x,z))$, and it's natural to interpret $\frac{\partial B}{\partial x}$ as $\frac{\partial f(x,g(x,z))}{\partial x}$. But the latter is equal to
$$\lim_{h\to 0}\frac{f(x+h,g(x,z))-f(x,g(x,z))}{h},$$ not
$$\lim_{h\to 0}\frac{f(x+h,g(x+h,z))-f(x,g(x,z))}{h},$$ which is what you calculated.

8. Sep 28, 2014

### hotvette

I think I understand, now. In my original post, I had $\partial B / \partial x$ twice in the same equation and they each represented different partials (as clarified in the limits you posted).

The question remains as to how to properly apply the chain rule (from the standpoint of notation) to find $\partial B / \partial x$ and $\partial B / \partial z$ when $B = f(x,y)$ and $y = g(x,z)$. That still isn't clear to me.

9. Sep 28, 2014

### Fredrik

Staff Emeritus
The constraints tell us that B=f(x,g(x,z)). We can introduce a new function h such that h(r,s)=f(r,g(r,s)) for all $r,s\in\mathbb R$. Then we have $B=f(x,g(x,z))=h(x,z)$. I would avoid the notation $\frac{\partial B}{\partial x}$, because it's not clear if it means
$$\frac{\partial}{\partial x}f(x,g(x,z)) =D_1f(x,g(x,z)),$$ or
$$\frac{\partial}{\partial x}h(x,z)=D_1h(x,z)=D_1f(x,g(x,z))+D_2f(x,g(x,z)) D_1g(x,z).$$ One trick I've seen is to use the notation $\left(\frac{\partial B}{\partial x}\right)_y$ for the former, and $\left(\frac{\partial B}{\partial x}\right)_z$ for the latter. The idea is that the subscript tells us which variable is "held constant" when we take the limit that defines the derivative, and that this indirectly tells us what function we're differentiating.

10. Sep 28, 2014

### hotvette

OK. Using that notation, we have:\begin{align*} &B = f(x,y) \\ &y = g(x,z) \\ &\left(\frac{\partial B}{\partial x}\right)_z = \left(\frac{\partial B}{\partial x}\right)_y + \left(\frac{\partial B}{\partial y} \cdot \frac{\partial y}{\partial x}\right) \\ &\left(\frac{\partial B}{\partial z}\right) = \left(\frac{\partial B}{\partial y} \cdot \frac{\partial y}{\partial z}\right) \end{align*} Correct??

11. Sep 28, 2014

### Fredrik

Staff Emeritus
I think you should probably write the left-hand side in the last one as $\left(\frac{\partial B}{\partial z}\right)_x$, to eliminate interpretations like this: We have $B=f(x,y)=f(x,g(x,z))=h(x,z)$ and $y=g(x,z)=x^3z$. If we solve the last one for x, we can write $B=h\big(\left(\frac{y}{z}\right)^{\frac 1 3},z\big)=p(y,z)$, and interpret $\frac{\partial B}{\partial z}$ as $D_2p(y,z)$ instead of as $D_2h(x,z)$.

Similarly, you may need to write $\left(\frac{\partial B}{\partial y}\right)_x$ instead of $\frac{\partial B}{\partial y}$, but I didn't think that one through.

I think it's a real pain to keep track of all these things in a calculation, so I usually try to express everything explicitly in terms of functions as early as possible, instead of in terms of variables with constraints that implicitly define functions.

12. Sep 29, 2014

### hotvette

Thanks. Issue resolved. My function B is a rather complicated function of sums of exponentials involving x,y and y is an exponential involving x, z. If I try to explicitly form $B(x,g(x,z))$ the result is nearly impossible to evaluate, but using the chain rule makes the problem straightforward. My ultimate goal was to see if $\partial B(x,g(x,z)) / \partial x = 0$ and I verified today that it does.

The thought just occurred to me that the problem might be better stated as:
\begin{align*} \frac{\partial B(x,z)}{\partial x} &= \left(\frac{\partial B(x,y)}{\partial x}\right) \cdot \left(\frac{\partial x}{\partial x}\right) + \left(\frac{\partial B(x,y)}{\partial y}\right) \cdot \left(\frac{\partial y(x,z)}{\partial x}\right) \\ % &= \left(\frac{\partial B(x,y)}{\partial x}\right) \cdot \left( 1 \right) + \left(\frac{\partial B(x,y)}{\partial y}\right) \cdot \left(\frac{\partial y(x,z)}{\partial x}\right) \\ % &= \left(\frac{\partial B(x,y)}{\partial x}\right) + \left(\frac{\partial B(x,y)}{\partial y}\right) \cdot \left(\frac{\partial y(x,z)}{\partial x}\right) \\ \\ % % % \frac{\partial B(x,z)}{\partial z} &= \left(\frac{\partial B(x,y)}{\partial z}\right) \cdot \left(\frac{\partial z}{\partial x}\right) + \left(\frac{\partial B(x,y)}{\partial y}\right) \cdot \left(\frac{\partial y(x,z)}{\partial z}\right) \\ % &= \left(0\right) \cdot \left(\frac{\partial z}{\partial x}\right) + \left(\frac{\partial B(x,y)}{\partial y}\right) \cdot \left(\frac{\partial y(x,z)}{\partial z}\right) \\ % &= \left(\frac{\partial B(x,y)}{\partial y}\right) \cdot \left(\frac{\partial y(x,z)}{\partial z}\right) \end{align*}

Last edited: Sep 30, 2014