Integral $\int_{-\infty}^\infty \frac{\tan^{-1}(x) - \tan^{-1}(x+a)}{(x-i)(x+a-i)} dx$ For $a\in\mathbb R$, I want to compute the integral
$$I = \int_{-\infty}^\infty \frac{\tan^{-1}(x) - \tan^{-1}(x+a)}{(x-i)(x+a-i)} dx.$$
Previously, I asked a question on a similar integral:
Integral $ \int_{-\infty}^\infty \frac{1}{x^2+1} \left( \tan^{-1} x + \tan^{-1}(a-x) \right) dx$
In that question, several ideas, such as (1) taking derivative with respect to $a$ or (2) contour integration, are suggested. However, both method seems to be not working for this integral.
This integral is motivated from physics calculation.
How can I evaluate $I$?
 A: Note that
\begin{align}
I(a)=&\int_{-\infty}^\infty \frac{\tan^{-1}x - \tan^{-1}\overset{x+a\to x}{(x+a)}}{(x-i)(x+a-i)} dx
=\int_{-\infty}^\infty \frac{\tan^{-1}x}{x-i}\Big(\frac{1}{x+a-i}-\frac{1}{x-a-i}\Big) dx
\end{align}
and it is straightforward to verify that $I=I^*$. Thus, it suffices to perform the integration on the real part, which can be expressed as
\begin{align}
J(a)=aI(a)
=& \int_{-\infty}^\infty \tan^{-1}x\Big(\frac{2x}{x^2+1}-\frac{x-a}{(x-a)^2+1} -\frac{x+a}{(x+a)^2+1}\Big) dx\\
 =& \int_{-\infty}^\infty \frac{2x\tan^{-1}- x\tan^{-1}(x-a)-x\tan^{-1}(x+a)} {x^2+1}dx
\end{align}
$$J’(a)=\int_{-\infty}^\infty \frac{x} {(x^2+1)((x-a)^2+1)}-\frac{x} {(x^2+1)((x+a)^2+1)}\> dx=\frac{2\pi a}{a^2+4}
$$
Then
$$I(a)=\frac1a \int_0^a J’(s)ds= \frac1a \int_0^a \frac{2\pi s}{s^2+4}ds= \frac{\pi}{a}\ln\Big(1+\frac{a^2}{4}\Big)
$$
A: Funny enough, but this integral can also be evaluated by means of the complex integration method.
$$I = \int_{-\infty}^\infty \frac{\tan^{-1}x - \tan^{-1}(x+a)}{(x-i)(x+a-i)} dx$$
$$=\int_{-\infty}^\infty \tan^{-1}x\Big(\frac{1}{(x-i)(x+a-i)}-\frac{1}{(x-a-i)(x-i)}\Big) dx$$
Making the substitution $t=-x$ in the second integral, we can write the initial integral in the form
$$I=\int_{-\infty}^\infty \tan^{-1}x\Big(\frac{1}{(x-i)(x+a-i)}+\frac{1}{(x+a+i)(x+i)}\Big) dx$$
Now, we use $\,\tan^{-1}x=\frac{1}{2i}\big(\ln(1+ix)-\ln(1-ix)\big)$, and
$$I=\frac{1}{2i}\int_{-\infty}^\infty \Big(\ln(1+ix)-\ln(1-ix)\Big)\Big(\frac{1}{(x-i)(x+a-i)}+\frac{1}{(x+a+i)(x+i)}\Big) dx$$
$$=\int_{-\infty}^\infty \frac{\ln(1+ix)}{2i(x+i)(x+a+i)}dx-\int_{-\infty}^\infty \frac{\ln(1-ix)}{2i(x-i)(x+a-i)}dx$$
$$+\int_{-\infty}^\infty \frac{\ln(1-ix)}{2i(x-i)(x+a-i)}dx-\int_{-\infty}^\infty \frac{\ln(1+ix)}{2i(x+i)(x+a+i)}dx$$
For the integrals with $\ln(1-ix)$ we close the contour in the upper half-plane (counterclockwise); for $\ln(1+ix)$ - in the lower half-plane (clockwise, in the negative direction). The first two integral "catches" the poles inside their contours; the other two - do not. Bearing in mind that the integration in the negative direction gives $-2\pi i$, we get:
$$I=-\frac{2\pi i}{2i}\operatorname{Res}_\binom{z=-i}{z=-a-i}\frac{\ln(1+iz)}{(z+i)(z+a+i)}-\frac{2\pi i}{2i}\operatorname{Res}_\binom{z=i}{z=-a+i}\frac{\ln(1-iz)}{(z-i)(z+a-i)}$$
$$=-\pi \,\Big(\frac{\ln2}{a}+\frac{\ln(2-ia)}{-a}+\frac{\ln2}{a}+\frac{\ln(2+ia)}{-a}\Big)=\frac{\pi}{a}\ln\Big(1+\frac{a^2}{4}\Big)$$
$$\boxed{\,\,I(a)=\frac{\pi}{a}\ln\Big(1+\frac{a^2}{4}\Big)\,\,}$$
Quick check: $\,I(a)=0\,\,\text{at}\,\, a=0\,$ and $\,a=\infty$.
