Can someone explain the chain rule used in this partial derivative? I thought I fully comprehended what the chain rule is when I was dealing with only single variable calculus. Now I moved onto partial derivative and came across this exercise problem. The chain rule used in this problem is just confusing as hell for me. Read multiple times still can't get the point. I'm learning math all by myself as a hobby and really need help here.
So the problem goes like this.
If $z=f(x,y)$ has continuous second-order partial derivatives and $x=r^2+s^2$ and $y=2rs$, find (a) $\frac{\partial{z}}{\partial{r}}$ and (b) $\frac{\partial^2{z}}{\partial{r^2}}$
(a) The chain rule gives
$\frac{\partial{z}}{\partial{r}}=\frac{\partial{z}}{\partial{x}}\frac{\partial{x}}{\partial{r}}+\frac{\partial{z}}{\partial{y}}\frac{\partial{y}}{\partial{r}}=\frac{\partial{z}}{\partial{x}}(2r)+\frac{\partial{z}}{\partial{y}}(2s)$
(b) Applying the product rule to the expression in part (a), we get
$\frac{\partial^2{z}}{\partial{r^2}}=\frac{\partial}{\partial{r}}(2r\frac{\partial{z}}{\partial{x}}+2s\frac{\partial{z}}{\partial{y}})=2\frac{\partial{z}}{\partial{x}}+2r\frac{\partial}{\partial{r}}(\frac{\partial{z}}{\partial{x}})+2s\frac{\partial}{\partial{r}}(\frac{\partial{z}}{\partial{y}})$
So I made upto this point. Now the author uses the chain rule once more and I am completely nowhere.
$\frac{\partial}{\partial{r}}(\frac{\partial{z}}{\partial{x}})=\frac{\partial}{\partial{x}}(\frac{\partial{z}}{\partial{x}})\frac{\partial{x}}{\partial{r}}+\frac{\partial}{\partial{y}}(\frac{\partial{z}}{\partial{x}})\frac{\partial{y}}{\partial{r}}=\frac{\partial^2{z}}{\partial{x^2}}(2r)+\frac{\partial^2{z}}{\partial{y}\partial{x}}(2s)$
$\frac{\partial}{\partial{r}}(\frac{\partial{z}}{\partial{y}})=\frac{\partial}{\partial{x}}(\frac{\partial{z}}{\partial{y}})\frac{\partial{x}}{\partial{r}}+\frac{\partial}{\partial{y}}(\frac{\partial{z}}{\partial{y}})\frac{\partial{y}}{\partial{r}}=\frac{\partial^2{z}}{\partial{x}\partial{y}}(2r)+\frac{\partial^2{z}}{\partial{y^2}}(2s)$
How did he use the chain rule here? In the equation $\frac{\partial}{\partial{r}}(\frac{\partial{z}}{\partial{x}})=\frac{\partial}{\partial{x}}(\frac{\partial{z}}{\partial{x}})\frac{\partial{x}}{\partial{r}}+\frac{\partial}{\partial{y}}(\frac{\partial{z}}{\partial{x}})\frac{\partial{y}}{\partial{r}}$, he puts $(\frac{\partial{z}}{\partial{x}})$ in the middle of $\frac{\partial}{\partial{x}}(\frac{\partial{z}}{\partial{x}})\frac{\partial{x}}{\partial{r}}$ and $\frac{\partial}{\partial{r}}$ becomes $\frac{\partial}{\partial{x}}\frac{\partial{x}}{\partial{r}}$ surrounding it. It seems all out of the blue.
I'm completely lost. I'm so depressed.
 A: I am writing for the part where you are having the difficulty .
It is clear to you if $z(x,y)$ is a function of $x,y$ (where $x$ and $y$ are both functions of $s$ and $r$) then
$\frac{\partial z}{\partial r}= \frac{\partial z}{\partial x}  \frac{\partial x}{\partial r}+ \frac{\partial z}{\partial y}  \frac{\partial y}{\partial r}  \quad (1)$
Now to find $\frac{\partial^2 z}{\partial r^2}  $,  let $\frac{\partial z}{\partial x}=u(x,y)$   and $\frac{\partial z}{\partial y}=v(x,y)$
So
$\frac{\partial }{\partial r} \big( \frac{\partial z}{\partial x}\big)= \frac{\partial }{\partial r}(u(x,y))$
Thus from $(1)$
$\frac{\partial u}{\partial r}= \frac{\partial u}{\partial x}  \frac{\partial x}{\partial r}+ \frac{\partial u}{\partial y}  \frac{\partial y}{\partial r} $
$=\frac{\partial^2 z}{\partial x^2}(2r)+\frac{\partial^2 z}{\partial y\partial x }  (2s)$
Now similarly find $\frac{\partial }{\partial r}\big(\frac{\partial z}{\partial y}\big)$ using $v(x,y)$ and the equality $(1)$ with which you are comfortable.
Substitute in the expression for $\frac{\partial^2 z}{\partial r^2}$ and you will get the required answer.
