How to use the chain rule (multivariable) to find an expression for the second derivative More specifically, I’m thinking about how to find a nice expression for $\frac{\partial^2 f}{\partial x^2}$ where we have an $f$ of the form $f(r(x,y), \varphi(x,y))$. If anyone could help me with this it would be greatly appreciated.
 A: The chain rule says:
$$ \frac{\partial f}{\partial x} = \frac{\partial f}{\partial r}\bigg|_{r(x,y)} \frac{\partial r}{ \partial x } +  \frac{\partial f}{\partial \phi}\bigg|_{\phi (x,y)} \frac{\partial \phi}{ \partial x }$$
Now, to take second derivative, all we have to do is product rule:
$$ \frac{\partial^2 f}{ \partial x^2}  = \left[\frac{ \partial}{\partial x}  \frac{\partial f}{\partial r}\bigg|_{r(x,y)} \right]\frac{\partial r}{ \partial x} + \frac{\partial f}{\partial r}\bigg|_{r(x,y)} \frac{\partial^2 r}{ \partial^2 x} +  \left[\frac{ \partial}{\partial x}  \frac{\partial f}{\partial \phi}\bigg|_{\phi(x,y)} \right]\frac{\partial \phi}{ \partial x} + \frac{\partial f}{\partial \phi}\bigg|_{\phi(x,y)} \frac{\partial^2 \phi}{ \partial^2 x}$$
Now, the tricky term is one in first square brackets:
$$ \frac{\partial}{\partial x} \frac{ \partial f}{\partial r} = \frac{ \partial^2 f}{ \partial^2 r}\bigg|_{r(x,y)} \frac{ \partial r}{ \partial x}$$
When we plug back in $ r(x,y)$ after the derivative, we will have to use chain rule again because this new function is dependent on $r$ which is inturn dependent on $ (x,y)$  and similar case for the $ \phi$ related terms.
Final expression:
$$ \frac{\partial^2 f}{\partial x^2} =  \frac{ \partial^2 f}{ \partial^2 r}\bigg|_{r(x,y)} \left( \frac{\partial r}{ \partial x} \right)^2 +  \frac{\partial f}{\partial r}\bigg|_{r(x,y)} \frac{\partial^2 r}{\partial x^2} +  \frac{ \partial^2 f}{ \partial^2 \phi}\bigg|_{\phi (x,y)} \left( \frac{\partial \phi}{ \partial x} \right)^2 +  \frac{\partial f}{\partial \phi}\bigg|_{\phi (x,y)} \frac{\partial^2 \phi }{\partial x^2}$$
