Partial derivative, show that problem. L.H.S to R.H.S This is a question from Advanced Calculus by David Wider.
If $u=f(x,y),x=r\cos(\theta)$ and $y=r\sin(\theta)$ show that
$$\frac{\partial u}{\partial x}^2+ \frac{\partial u}{\partial y}^2 = \frac{\partial u}{\partial r}^2 + \frac{\partial
 u}{\partial \theta}^2\frac{1}{r^2}$$
So far I have said the following
\begin{align}&\frac{\partial u}{\partial x}=\frac{\partial u}{\partial r}\frac{\partial r}{\partial x}=
\frac{\partial u}{\partial r}\frac{1}{(\frac{\partial x}{\partial r})}=\frac{\partial u}{\partial r}\frac{1}{\cos\theta} \\
\Rightarrow 
&\frac{\partial u}{\partial x}^2=\frac{\partial u}{\partial r}^2\frac{1}{\cos^2\theta}\text{, and } \frac{\partial u}{\partial y}=\frac{\partial u}{\partial \theta}\frac{\partial \theta}{\partial y}=\frac{\partial u}{\partial \theta}\frac{1}{(\frac{\partial y}{\partial \theta})}=\frac{\partial u}{\partial \theta}\frac{1}{-r\cos\theta} \\
 \Rightarrow
&\frac{\partial u}{\partial y}^2=\frac{\partial u}{\partial \theta}^2\frac{1}{r^2\cos^2\theta}  \\
&\text{ taking the sum ( the L. H .S) we get the following }\\
&\frac{\partial u}{\partial r}^2\frac{1}{\cos^2\theta}+\frac{\partial u}{\partial \theta}^2\frac{1}{r^2\cos^2\theta}=\frac{1}{\cos^2 \theta}(\frac{\partial u}{\partial r}^2+ \frac{\partial
 u}{\partial \theta}^2\frac{1}{r^2})
\end{align}
given my certainty about the fact that $\frac{1}{\cos^2 \theta}$ not equalling 1 can say I have made a mistake could someone please point it out or provide a complete solution that would be apricated. I suspect my mistake might be around my inversion of the partial derivatives but i am not sure.
 A: The error lies in the application of the chain rule for multivariate functions $u(x, y) , x(r, \theta), y(r, \theta)$.
\begin{align}
\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 u }{\partial x} \cos(\theta) + \frac{\partial u }{\partial y} \sin(\theta)
\end{align}
Similarly,
\begin{align}
\frac{\partial u }{\partial \theta} = \frac{\partial u }{\partial x} \frac{\partial x }{\partial \theta} + \frac{\partial u }{\partial y} \frac{\partial y }{\partial \theta}  = -\frac{\partial u }{\partial x} r\sin(\theta) + \frac{\partial u }{\partial y} r \cos(\theta).
\end{align}
Thus, \begin{align}
\bigg( \frac{\partial u }{\partial r} \bigg)^2 = \bigg(\frac{\partial u }{\partial x} \bigg)^2\cos(\theta)^2 + \bigg(\frac{\partial u }{\partial y} \bigg)^2 \sin(\theta)^2+ 2 \cos(\theta) \sin(\theta) \frac{\partial u }{\partial x} \frac{\partial u }{\partial y} 
\end{align}
and
\begin{align}
\bigg(\frac{\partial u }{\partial \theta}\bigg)^2 = r^2\bigg(\frac{\partial u }{\partial x} \bigg)^2\sin(\theta)^2 + r^2\bigg(\frac{\partial u }{\partial y} \bigg)^2 \cos(\theta)^2- 2r^2 \cos(\theta) \sin(\theta) \frac{\partial u }{\partial x} \frac{\partial u }{\partial y}.
\end{align}
Invoking $\sin(\theta)^2 + \cos(\theta)^2 = 1$ yields the claimed relationship.
A: Alternatively using your approach with the fixed of chain rule for multivariables real functions, we get
$$\frac{\partial u}{\partial x}=\frac{\partial u}{\partial r}\frac{\partial r}{\partial x}+\frac{\partial u}{\partial \theta}\frac{\partial \theta}{\partial x}, \quad \text{and}\quad \frac{\partial u}{\partial y}=\frac{\partial u}{\partial r}\frac{\partial r}{\partial y}+\frac{\partial u}{\partial \theta}\frac{\partial \theta}{\partial y}$$
Since
$$r^{2}=x^{2}+y^{2},\quad  \text{and}\quad \theta=\tan^{-1}\frac{y}{x}$$
Hence,
$$\frac{\partial r}{\partial x}=\frac{x}{r},\quad \frac{\partial r}{\partial y}=\frac{y}{r},\quad \frac{\partial \theta}{\partial x}=-\frac{y}{r^{2}},\quad \text{and}\quad \frac{\partial \theta}{\partial y}=\frac{x}{r^{2}}$$
Therefore,
$$\left(\frac{\partial u}{\partial x}\right)^{2}+\left(\frac{\partial u}{\partial y}\right)^{2}=\left(  \frac{x}{r}\frac{\partial u}{\partial r}-\frac{y}{r^{2}}\frac{\partial u}{\partial \theta }\right)^{2}+\left(\frac{y}{r}\frac{\partial u}{\partial r}+\frac{x}{r^{2}}\frac{\partial u}{\partial \theta}\right)^{2}$$ $$=\left(\frac{\partial u}{\partial r}\right)^{2}+\frac{1}{r^{2}}\left(\frac{\partial u}{\partial\theta}\right)^{2}$$
as desired.
