polar coordinates and derivatives
Using the standard notation $(x,y)$ for cartesian coordinates, and $(r, \theta)$ for polar coordinates, it is true that $$ x = r \cos \theta$$ and so we can infer that $$ \frac{\partial x}{\partial r} = \cos \theta.$$ This means that if we perturb $r$ to $r+\Delta r$, $x$ gets perturbed to approximately $x+ \cos(\theta) \Delta r$. This is equivalent to saying that if we perturb $x$ to $x+\Delta x$, then we perturb $r$ to approximately $r+ (1/\cos \theta) \Delta x$. Correspondingly, we expect that $$ \frac{\partial r}{\partial x} = \frac{1}{\cos \theta}.$$ In fact, $$ \frac{ \partial r}{\partial x} = \frac{\partial}{\partial x} \sqrt{x^2+y^2}= \frac{2x}{2 \sqrt{x^2+y^2}} = \frac{x}{r} = \cos \theta.$$ What gives?
When you take partial derivatives, what you are doing is to hold the other variable fixed. So for instance if $f$ is a function of $n$ variables, $f(x_1,x_2,\ldots,x_n)$, $\frac{\partial f}{\partial x_i}$ means you hold all the other $x_j$'s constant except $x_i$ and vary $x_i$ by $\delta x_i$ and find out what happens to $\delta f$.
We have
$x= r \cos(\theta)$,$y= r \sin(\theta)$, $r^2= x^2 + y^2$ and $\tan(\theta) = \frac{y}{x}$.
We are transforming from the $(x,y)$ space to $(r,\theta)$ space.
In the $(x,y)$ space, $x$ and $y$ are independent variables and In the $(r,\theta)$ space, $r$ and $\theta$ are independent variables.
$\frac{\partial x}{\partial r}$ means you are fixing $\theta$ and finding out how changing $r$ affects $x$.
So $\frac{\partial x}{\partial r} = \cos(\theta)$ since $\theta$ is fixed.
$\frac{\partial r}{\partial x}$ means you are fixing $y$ and finding out how changing $x$ affects $r$.
So $\frac{\partial r}{\partial x} = \frac{x}{\sqrt{x^2+y^2}}$ since $y$ is fixed.
When you do $r = \frac{x}{\cos(\theta)}$ and argue that $\frac{\partial r}{\partial x} = \frac{1}{\cos (\theta)}$ you are not holding $y$ constant.
If you were to hold $y$ constant, then $\theta$ would change as well.
EDIT:
I am adding this in the hope that this will make it a bit more clear. If you want to use $r = \frac{x}{\cos(\theta)}$ and still derive it, you need to do as follows:
$r = \frac{x}{\cos(\theta)}$, $\delta r = \frac{\delta x}{\cos(\theta)} + \frac{-x}{\cos^2(\theta)} (-\sin(\theta)) \delta \theta$.
$\tan(\theta) = \frac{y}{x} \Rightarrow x \tan(\theta) = y$
$\delta x \tan(\theta) + x \sec^2(\theta) \delta \theta = 0$ (Since $y$ is held constant)
$x \delta \theta = - \frac{\delta x \tan(\theta)}{\sec^2{\theta}} = - \sin(\theta) \cos(\theta) \delta x$.
Plugging the above in the previous expression, we get
$\delta r = \frac{\delta x}{\cos(\theta)} + \frac{\sin(\theta)}{\cos^2(\theta)} (-\sin(\theta) \cos(\theta) \delta x) = \frac{1-\sin^2(\theta)}{\cos(\theta)} \delta x = \cos(\theta) \delta x$ and hence we get
$\frac{\partial r}{\partial x} = \cos(\theta) = \frac{x}{\sqrt{x^2+y^2}}$