This question is a particular case of the following:
Suppose that X ∼ U ( $− π/2$ , $π/2$ ) . Find the pdf of Y = tan(X).
I came up at the same solution in the following post, ignoring for a moment the real data of the problem, that is $X \sim U (-\pi ,\pi)$ and not $X \sim U ( -\pi/2 ,\pi/2)$.
Due to this change in the domain of $X$, I split the problem in 3 parts and summed up:
$P(-\pi/2 \le x \le \arctan(y)) +P(\pi/2 \le x \le \pi-\arctan(y)) +P(-\pi \le x \le - \pi + \arctan(y)) $
Is this approach correct?
If you look at the graph of $\tan(x)$, you see that you have two cases:
If $y<0$, then:
$$P(Y\le y) = P(\tan(X)\le y)=\\P(-\pi/2\lt X\le \arctan(y))+P(\pi/2\lt x\le\arctan(y)+\pi)$$
If $y\ge0$, then:
$$P(Y\le y) = P(\tan(X)\le y)=\\P(-\pi\lt X\le \arctan(y)-\pi)+P(-\pi/2\lt x\le\arctan(y))+P(\pi/2\lt x\lt\pi)$$
In both cases: $$F_Y(y)=P(Y\le y) = \frac{1}{2\pi}(2\arctan(y)+\pi)$$
By differentiation one gets: $$f_Y(y)=\frac{1}{\pi(1+y^2)}$$