Trouble with definite integral calculating probabilities I cannot solve this:
$$\int_{-\frac{\pi }{2}}^{\frac{\pi }{2}} \tan ^{-1}(a+\tan (x)) \, dx$$
it apeared when trying to find out the probability:
$$P\{\tan a - \tan b \leq 2x\},\ \   0 < x < 1\sqrt{3}$$
Knowing that the joint distribution $f(a,b)$ is
$f(a,b) = \frac{2}{\pi^2}$ in the region $-\pi/2 < b < a < \pi/2$ (triangle)
"$a$" has marginal density:
$\frac{2x+\pi}{\pi^2}$ where $-\pi/2 < a < \pi/2$.
and "$b$" has density: $\frac{\pi-2x}{\pi^2}$ being $ -\pi/2 < b < a$.

An approach that is less elegant but more elementary than residues.
Let
$$
J(b) = \int_{-\pi/2}^{\pi/2} \tan^{-1} \left( 2b + \tan x \right) dx.
$$
Then $J(0) = 0$ and using the substitution $\tan x = t$,
$$
\begin{align}
J'(b) &= \int_{-\infty}^\infty \frac{2}{(1+t^2)(1+(t+2b)^2)} dt
= \int_{-\infty}^\infty \frac{dt}{b(1+b^2)}\left[ \frac{3 b+t}{4 b^2+4 b t+t^2+1}+\frac{b-t}{t^2+1}\right]
\\&= \left.\frac{dt}{2b(1+b^2)}\left[ \log \left(\frac{4 b^2+4 b t+t^2+1}{t^2+1}\right)+2 b \tan ^{-1}(t)+2 b \tan ^{-1}(2 b+t)\right] \right\lvert_{-\infty}^\infty
\\&= \frac{\pi}{1+b^2}.
\end{align}
$$
By integrating back,
$$
J(b) = \int_0^b \frac{\pi \,db'}{1+b'^2} = \pi \tan^{-1} b.
$$
