How to get x from $\tan(x)$ knowing the sign of $\cos(x)$ and $\sin(x)$ I have access to tan(x) and I want to deduce x from it. However if use the inverse of tan(x) I got x[$\pi$] and not directly x. For example:
$$tan^{-1}(tan(\pi)) = 0 $$
Knowing the sign of cos(x) and sin(x) is there a way I can correct this to have the value of x in the interval $ [0,2\pi)$ ?
 A: hint
For each real $ x\le 0$
$$\frac{-\pi}{2}<tan^{-1}(x)\le 0$$
and for $ x\ge 0,$
$$0\le tan^{-1}(x)<\frac{\pi}{2}$$
For example, assume $$\tan(x)=a$$
$$\cos(x)\le 0$$
$$\sin(x)\ge 0$$
then
$$x = tan^{-1}(a)+\pi$$
A: The triple $(\tan x, \sin x, \cos x)$ is periodic with minimal period $2\pi$, so the best you can do with the information you have is to find the equivalence class of such $x$s modulo $2\pi$.
$$  \hat{x} = \begin{cases}
\arctan \tan x ,& \cos x > 0 \text{ and } \sin x \geq 0,  \\
\pi/2 ,& \cos x = 0 \text{ and } \sin x = 1,  \\
\pi + \arctan \tan x ,& \cos x < 0,  \\
3\pi/2 ,& \cos x = 0 \text{ and } \sin x = -1, \\
2 \pi + \arctan \tan x ,& \cos x > 0 \text{ and } \sin x < 0
\end{cases}  $$
The first case handles the quadrantal angle zero and the first quadrant.  The second case handles the quadrantal angle $\pi/2$.  The third case handles the second and third quadrants as well as the quadrantal angle $\pi$ between them.  The fourth case handles the quadrantal angle $3\pi/2$.  The fifth cases handles the fourth quadrant.
Then $\hat{x} \in [0,2\pi)$ and $x = \hat{x} + 2\pi k$, for some integer $k$.
