It would help if someone can explain to me what I read in my book.
The equation is $x=rcos\theta$. We want to find $\frac{\partial r}{\partial x}$. One way to find it is to leave the equation as is and find $\frac{\partial x}{\partial r}$, which is $cos\theta$ and take the reciprocal of that to get $\frac{1}{cos\theta}$. The other way is to tweak the equation to be $r=\frac{x}{cos\theta}$ and find $\frac{\partial r}{\partial x}$ straight away and get $\frac{1}{cos\theta}$.
But then, here is where I get confused. The author says because we know $r=\sqrt{x^2+y^2}$, we can then find $\frac{\partial r}{\partial x}=\frac{x}{\sqrt{x^2+y^2}}=\frac{x}{r}=cos\theta$. The author explains the reason we are getting this answer is because here, instead of holding $\theta$ constant, we are pre-supposing $y$ to be constant and when $x$ varies, both $\theta$ and $r$ vary. Finally because this is not partial derivative by its definition, $cos\theta$ is rejected as a answer.