Partial derivatives of $g(x,y,z)=f(x-y,y-z,z-x)$. Let $f$ be two times differentiable function of variables $u,w,v$ and define $g(x,y,z)=f(x-y,y-z,z-x)$. Determine $\frac{\partial g}{\partial x}+\frac{\partial g}{\partial y}+\frac{\partial g}{\partial z}$ and express $\frac{\partial^2 g}{\partial x^2}$ in partial derivates of $f$.
This is from calc 3. I don't know how to solve this at all but I suspect there is some easy rule to do this. Help would be appreciated.
 A: Hint:  Notice that we can use a tree diagram. Then with a change of variables $g(x,y,z)=f(u,v,w)$ and finally Chain rule.

A: Chain rule, as proposed in the comments, is a sure path. However, it may generate quite bulky expressions, that is why it's judicious to prepare the ground by computing the differential of $g$ first. Renaming the variables as
$$
\begin{cases}
   t_1 = x-y \\
   t_2 = y-z \\
   t_3 = z-x
\end{cases}
$$
we can write
$$
\begin{array}{rcl}
\mathrm{d}g 
   &=&
   \mathrm{d}(f(x-y,y-z,z-x)) \\
   &=&
   f_1(t_1,t_2,t_3)\mathrm{d}t_1 + f_2(t_1,t_2,t_3)\mathrm{d}t_2 + f_3(t_1,t_2,t_3)\mathrm{d}t_3 \\
   &=&
   f_1(t_1,t_2,t_3)(\mathrm{d}x-\mathrm{d}y) \;+\\&& f_2(t_1,t_2,t_3)(\mathrm{d}y-\mathrm{d}x) \;+\\&& f_3(t_1,t_2,t_3)(\mathrm{d}z-\mathrm{d}x) \\
   &=&
   (f_1(t_1,t_2,t_3)-f_3(t_1,t_2,t_3))\mathrm{d}x \;+\\&& (f_2(t_1,t_2,t_3)-f_1(t_1,t_2,t_3))\mathrm{d}y \;+\\&& (f_3(t_1,t_2,t_3)-f_2(t_1,t_2,t_3))\mathrm{d}z
\end{array}
$$
where the indices denote partial derivatives. In consequence, we have :
$$
\frac{\partial g}{\partial x} + \frac{\partial g}{\partial y} + \frac{\partial g}{\partial z} = (f_1-f_3) + (f_2-f_1) + (f_3-f_2) = 0
$$
You can apply the same procedure to obtain $\frac{\partial^2g}{\partial x^2}$. Indeed, consdering the differental $g_x = \frac{\partial g}{\partial x}$, i.e.
$$
\begin{array}{rcl}
\mathrm{d}g_x 
   &=&
   \mathrm{d}(f_1(t_1,t_2,t_3)-f_3(z_1,z_2,z_3)) \\
   &=&
   f_{11}(t_1,t_2,t_3)\mathrm{d}t_1 + f_{12}(t_1,t_2,t_3)\mathrm{d}t_2 + f_{13}(t_1,t_2,t_3)\mathrm{d}t_3 \;-\\&& f_{31}(t_1,t_2,t_3)\mathrm{d}t_1 - f_{32}(t_1,t_2,t_3)\mathrm{d}t_2 - f_{33}(t_1,t_2,t_3)\mathrm{d}t_3 \\
   &=&
   \ldots \\
   &=&
   (f_{11}-2f_{13}+f_{33})\mathrm{d}x + (\ldots)\mathrm{d}y +(\ldots)\mathrm{d}z
\end{array}
$$
we find that
$$
\frac{\partial^2g}{\partial x^2} = f_{11}(t_1,t_2,t_3)-2f_{13}(t_1,t_2,t_3)+f_{33}(t_1,t_2,t_3)
$$
A: If $\mathbf{h}:\mathbb{R}^3\to\mathbb{R}^3,\ \begin{pmatrix}x\\ y\\ z\end{pmatrix}\mapsto\begin{pmatrix}u\\ v\\ w\end{pmatrix}=\begin{pmatrix}x-y\\ y-z\\ z-x\end{pmatrix}$ and $f:\mathbb{R}^3\to\mathbb{R},\ \begin{pmatrix}u\\ v\\ w\end{pmatrix}\mapsto f\begin{pmatrix}u\\ v\\ w\end{pmatrix}$ then $g=f\circ\mathbf{h}:\mathbb{R}^3\to\mathbb{R},\ \begin{pmatrix}x\\ y\\ z\end{pmatrix}\mapsto \mathbf{g}\begin{pmatrix}x\\ y\\ z\end{pmatrix}=f\begin{pmatrix}x-y\\ y-z\\ z-x\end{pmatrix}$ so
\begin{align*}
Dg\begin{pmatrix}x\\ y\\ z\end{pmatrix}&=\begin{bmatrix}\frac{\partial g}{\partial x} & \frac{\partial g}{\partial y} & \frac{\partial g}{\partial z}\end{bmatrix}=D(f\circ\mathbf{h})\begin{pmatrix}x\\ y\\ z\end{pmatrix}=Df\left(\mathbf{h}\begin{pmatrix}x\\ y\\ z\end{pmatrix}\right)D\mathbf{h}\begin{pmatrix}x\\ y\\ z\end{pmatrix}=Df\begin{pmatrix}u\\ v\\ w\end{pmatrix}D\mathbf{h}\begin{pmatrix}x\\ y\\ z\end{pmatrix}\\
&=\begin{bmatrix}\frac{\partial f}{\partial u} & \frac{\partial f}{\partial v} & \frac{\partial f}{\partial w}\end{bmatrix}\begin{bmatrix}\frac{\partial u}{\partial x} & \frac{\partial u}{\partial y} & \frac{\partial u}{\partial z}\\ \frac{\partial v}{\partial x} & \frac{\partial v}{\partial y} & \frac{\partial v}{\partial z}\\ \frac{\partial w}{\partial x} & \frac{\partial w}{\partial y} & \frac{\partial w}{\partial z}\end{bmatrix}
= \begin{bmatrix}\frac{\partial f}{\partial u} & \frac{\partial f}{\partial v} & \frac{\partial f}{\partial w}\end{bmatrix}\begin{bmatrix}1 & -1 & 0\\ 0 & 1 & -1\\ -1 & 0 & 1\end{bmatrix}\\
&=\begin{bmatrix}\frac{\partial f}{\partial u}-\frac{\partial f}{\partial w} & -\frac{\partial f}{\partial u}+\frac{\partial f}{\partial v} & -\frac{\partial f}{\partial v}+\frac{\partial f}{\partial w}\end{bmatrix}
\end{align*}
which implies $$\frac{\partial g}{\partial x}=\frac{\partial f}{\partial u}-\frac{\partial f}{\partial w},\quad \frac{\partial g}{\partial y}=-\frac{\partial f}{\partial u}+\frac{\partial f}{\partial v},\quad \frac{\partial g}{\partial z}=-\frac{\partial f}{\partial v}+\frac{\partial f}{\partial w}$$
and it follows that $$\frac{\partial g}{\partial x}+\frac{\partial g}{\partial y}+ \frac{\partial g}{\partial z}=0.$$
Now $$\frac{\partial^2 g}{\partial x^2}=\frac{\partial}{\partial x}\left(\frac{\partial g}{\partial x}\right)=\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial u}-\frac{\partial f}{\partial w}\right)=\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial u}\right)-\frac{\partial }{\partial x}\left(\frac{\partial f}{\partial w}\right)=\frac{\partial^2 f}{\partial u^2}-\frac{\partial^2 f}{\partial w \partial u}-\frac{\partial^2 f}{\partial u\partial w}+\frac{\partial^2 f}{\partial w^2}$$ since
\begin{align*}
\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial u}\right)=\begin{bmatrix}\frac{\partial^2 f}{\partial u^2} & \frac{\partial^2 f}{\partial v\partial u} & \frac{\partial^2 f}{\partial w\partial u}\end{bmatrix}\begin{bmatrix}\frac{\partial u}{\partial x}\\ \frac{\partial v}{\partial x}\\ \frac{\partial w}{\partial x}\end{bmatrix}=\begin{bmatrix}\frac{\partial^2 f}{\partial u^2} & \frac{\partial^2 f}{\partial v\partial u} & \frac{\partial^2 f}{\partial w\partial u}\end{bmatrix}\begin{bmatrix}1\\ 0\\ -1\end{bmatrix}=\frac{\partial^2 f}{\partial u^2}-\frac{\partial^2 f}{\partial w \partial u}
\end{align*}
and
\begin{align*}
\frac{\partial }{\partial x}\left(\frac{\partial f}{\partial w}\right)=\begin{bmatrix}\frac{\partial^2 f}{\partial u\partial w} & \frac{\partial^2 f}{\partial v\partial w} & \frac{\partial^2 f}{\partial w^2}\end{bmatrix}\begin{bmatrix}\frac{\partial u}{\partial x}\\ \frac{\partial v}{\partial x}\\ \frac{\partial w}{\partial x}\end{bmatrix}=\begin{bmatrix}\frac{\partial^2 f}{\partial u\partial w} & \frac{\partial^2 f}{\partial v\partial w} & \frac{\partial^2 f}{\partial w^2}\end{bmatrix}\begin{bmatrix}1\\ 0\\ -1\end{bmatrix}=\frac{\partial^2 f}{\partial u\partial w}-\frac{\partial^2 f}{\partial w^2}.
\end{align*}
