Inconsistency in partial derivatives in polar and Cartesian coordinates

We know that for polar $(r,\theta)$ and Cartesian $(x,y)$ coordinates:

$r=\sqrt{x^2+y^2}$ (1)

$x=r\cos\theta$ (2)

I am trying to find $\dfrac{\partial r}{\partial x}$. I have tried two methods, which do not give the same answer, and I want to know where I've gone wrong.

Method 1:

Use equation (1) to get

$$\frac{\partial r}{\partial x}=\frac{x}{\sqrt{x^2+y^2}}=\frac{r\cos\theta}{r}=\cos\theta$$

Method 2:

Use equation (2) to write

$$r=\frac{x}{\cos\theta}$$ so $$\frac{\partial r}{\partial x}=\frac{1}{\cos\theta}$$

I think that it's Method 1 that's correct, but I can't see what the mistake is that I've made in Method 2. I'm sure it's blindingly obvious, but any advice would be highly appreciated.

• I see the problem. The first answer is the partial derivative of r with respect to x with theta held constant, while the second answer is the partial derivative of r with respect to x with cos(theta) held constant. – Mr. Bump Apr 10 '16 at 10:53

The mistake in the second part is that $\theta$ depends on $x$ as well. For instance, if $x>0$ you have $$\theta=\arctan \frac yx$$
Further explanation: In this problem you have two functions $r(x,y)$ and $\theta(x,y)$ so, in order to calculate partial derivatives such as $\dfrac{\partial r}{\partial x}$ you must first write $r$ as a function of $(x,y)$, differentiate it to obtain the function $\dfrac{\partial r}{\partial x}(x,y)$ and after try to express $\dfrac{\partial r}{\partial x}$ as a function of $(r,\theta)$. You did it correctly in the first case.
In the second one, however, you actually did the following $$\frac{\partial }{\partial x}\left[\frac{x}{\cos(\theta(x,y))}\right]=\frac{1}{\cos(\theta(x,y))}\frac{\partial}{\partial x}[x]$$ which is false, because $\cos(\theta(x,y))$ is not constant: it is actually $\dfrac{x}{\sqrt{x^2+y^2}}$