Currently doing a problem where I need to find $\frac {\partial \theta}{\partial x}$. However, for $\tan(\theta)= \dfrac yx$, $\frac {\partial\theta}{\partial x}$ is yielding $- \dfrac{\sin(\theta)}{r}$, while for $x= r \cos(\theta)$, $\dfrac {\partial\theta}{\partial x}$ is yielding $\dfrac 1{-r\sin(\theta)}$. Why aren't these matching/where's my error? From what I understand, these are both valid ways to convert from Cartesian to polar coordinates. Work shown below.
$$\tan(\theta)=\frac yx \implies \sec^2(\theta)\dfrac {\partial \theta}{\partial x} = -\frac y{x^2}$$ $$\require{enclose}\implies \frac {\partial \theta}{\partial x} = -\frac {y}{x^2\sec^2(\theta)}=-\frac {y\cos^2(\theta)}{x^2}=-\frac {x\sin(\theta)\cos^2(\theta)}{r^2\cos^2(\theta)} = \enclose{box}{-\frac {\sin(\theta)}{r} = \frac {\partial \theta}{\partial x}}$$ $$x=r\cos(\theta) \implies \frac {\partial x}{\partial x} = 1 = -r\sin(\theta)\frac {\partial \theta}{\partial x} \implies \enclose{box}{\frac {\partial \theta}{\partial x} = -\frac 1{r\sin(\theta)}}$$
Figured out what I did wrong. My implicit differentiation of $x= r \cos(\theta)$ was incorrect.
As user_of_math pointed out, $x= x(r, \theta)$. In other words, x is dependent on not just $\theta$, but $r$ as well. Thus, r cannot be treated as a constant. So the differentiation would be as follows.
$$x=r\cos(\theta) \implies \frac {\partial x}{\partial x} = 1 = \frac {\partial r}{\partial x} cos(\theta) - r sin\frac {\partial\theta}{\partial x}$$
Now we need $\frac {\partial r}{\partial x}$. From $x^2 + y^2= r^2$, $$\frac {\partial}{\partial x} [x^2 + y^2] = \frac {\partial}{\partial x} r^2 \implies 2x= 2r \frac {\partial r} {\partial x} \implies \frac {\partial r} {\partial x} = \frac {x}{r} = cos(\theta)$$
Plug $\frac {\partial x}{\partial r} in$, and one obtains $$1= cos^2(\theta)- rsin(\theta) \frac {\partial\theta}{\partial x} \implies sin^2(\theta)= -rsin(\theta) \frac {\partial \theta}{\partial x} \implies $$
$$ \frac {\partial \theta}{\partial x}= \frac {-sin(\theta)}{r}$$.