We can get the angle between $x$ and $y$ (or $\cos{\theta}$ and $\sin{\theta}$ respectively) from $$ \theta =\tan^{-1}{\frac{y}{x}} $$ but only if $ -\frac{\pi}{2} < \theta < \frac{\pi}{2} $ since the cases with negative $x$ and/or $y$ exist where $$ \tan^{-1}{\frac{-y}{-x}} = \tan^{-1}{\frac{y}{x}} $$ and $$ \tan^{-1}{\frac{-y}{x}}=\tan^{-1}{\frac{y}{-x}}. $$ Let's also not ignore division by zero at $|\theta| = \pi/2$.
When coding, I can often (in many coding languages) do something like
theta = (y>=0)*arccos(x) + (y<0)*(2*pi - arccos(x))
where y>=0
and y<0
are boolean expressions that evaluate to $1$ or $0$ if the statements $y\geq 0$ and $y<0$ are true or false respectively, but this is not an expression I find easy to work with in pure math.
What is a good mathematical way to express the angle for all four quadrants as an expression/function of $x$ and $y$? Sometimes I might want a function that is differentiable, and then I don't think I want to involve boolean statements in the mathematics since I am not very experienced with that kind of math, but I am open-minded. It must be differentiable at least.