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$.

$$\tan{u} = a + \tan{x} \implies x=\arctan{(\tan{u}-a)} \implies dx = \frac{\sec^2{u}}{1+(\tan{u}-a)^2} du $$
Then the integral is equal to 
$$\begin{align}\int_{-\pi/2}^{\pi/2} du \frac{u \sec^2{u}}{1+(\tan{u}-a)^2} &= \int_{-\pi/2}^{\pi/2} du \frac{u}{\cos^2{u} + (\sin{u}-a \cos{u})^2} \\ &= \frac12 \int_{-\pi}^{\pi} dv \frac{v}{2+a^2+a^2 \cos{v}-2 a \sin{v}} \end{align}$$
Let
$$J(\beta) = -\frac{i}{2} \int_{-\pi}^{\pi} dv \frac{e^{i \beta v}}{2+a^2+a^2 \cos{v}-2 a \sin{v}} $$
Then the integral we seek is $J'(0)$.
Consider the integral
$$-\oint_C dz \frac{z^{\beta}}{(a^2+i 2 a) z^2+(a^2+2) z+(a^2-i 2 a)} $$
where $C$ is the contour pictured below:

i.e., a unit circle with a keyhole about the negative real axis.  The contour integral is then
$$J(\beta) - i 2\sin{\pi \beta} \int_0^1 dx \frac{x^{\beta}}{(a^2+i 2 a) x^2-(a^2+2) x+(a^2-i 2 a)}$$
This is also equal to $-i 2 \pi$ times the residue at the pole $z_0=-a/(a+i 2)$ inside $C$, which is $z_0^{\beta}/2$.  Thus,
$$\begin{align}J'(0) &= i 2 \pi \int_0^1 \frac{dx}{(a^2+i 2 a) x^2-2 (a^2+2) x+(a^2-i 2 a)} - i \frac{\pi}{2} \log{z_0} \\ &= \frac{1}{2} \pi  \arctan\left(\frac{a}{2}\right)-\frac{1}{4} i \pi  \log \left(\frac{4}{a^2}+1\right) + \frac{1}{2} \pi  \arctan\left(\frac{a}{2}\right)+\frac{1}{4} i \pi  \log \left(\frac{4}{a^2}+1\right) \\ &= \pi \arctan{\left ( \frac{a}{2}\right )} \end{align}$$
