TITLE: What is the Arctangent of Tangent?
QUESTION [5 upvotes]: This is probably just me misunderstanding trig properties. I remember from my trig days that $\tan(\arctan(x)) = x$ But I can't remember if that holds the other way. Can someone help me out? Is this valid:
$$\arctan(\tan(\theta)) = \theta$$

REPLY [9 votes]: It is true that $\tan\arctan x=x$, for every $x$. The converse is not true and it cannot be, because the tangent is not an injective function.
Recall that $\arctan x$ returns a number (an angle if you prefer) in the interval $(-\pi/2,\pi/2)$. So we have the equality
$$
\arctan(\tan\theta)=\theta
$$
if and only if $\theta\in(-\pi/2,\pi/2)$.
A formula can be given for any $\theta$: you just need to “reduce” the angle to the right interval by subtracting an integral multiple of $\pi$ so that
$$
-\frac{\pi}{2}<\theta-k\pi<\frac{\pi}{2}
$$
which is equivalent to
$$
-\frac{1}{2}<\frac{\theta}{\pi}-k<\frac{1}{2}
$$
or
$$
0<\frac{\theta}{\pi}+\frac{1}{2}-k<1
$$
or
$$
k<\frac{\theta}{\pi}+\frac{1}{2}<k+1
$$
which means
$$
k=\left\lfloor\frac{\theta}{\pi}+\frac{1}{2}\right\rfloor
$$
Thus
$$
\arctan(\tan\theta)=\theta-\pi\left\lfloor\frac{\theta}{\pi}+\frac{1}{2}\right\rfloor
$$
(of course when $\tan\theta$ is defined to begin with).
For instance, if $\theta=15\pi/4$, we have
$$
\left\lfloor\frac{\theta}{\pi}+\frac{1}{2}\right\rfloor=
\left\lfloor\frac{15}{4}+\frac{1}{2}\right\rfloor=4
$$
and
$$
\arctan\tan\frac{15\pi}{4}=\frac{15\pi}{4}-4\pi=-\frac{\pi}{4}
$$