<s>[INST] integral with $\log\left(\frac{x+1}{x-1}\right)$ I encountered a tough integral and I am wondering if anyone has any ideas on how to evaluate it.
$$\displaystyle \int_{0}^{\infty}\frac{x}{x^{2}+a^{2}}\log\left(\left|\frac{x+1}{x-1}\right|\right)dx=\pi\tan^{-1}(1/a), \;\ a>1$$
I tried breaking up the log and differentiating w.r.t 'a', but did not make considerable progress. Is it possible to do this one with residues?. 
I attempted to write it as $$\displaystyle \frac{1}{a^{2}}\int_{0}^{\infty}\frac{x}{1+(x/a)^{2}}\log(x+1)dx-\frac{1}{a^{2}}\int_{0}^{\infty}\frac{x}{1+(x/a)^{2}}\log(x-1)dx$$
Now, make the sub $t=x/a, \;\ dx=adt$
$\displaystyle \int_{0}^{\infty}\frac{t}{1+t^{2}}\log(1+at)dt-\int_{0}^{\infty}\frac{t}{1+t^{2}}\log(at-1)dt$
Differentiate w.r.t 'a' gives:
$$\displaystyle \int_{0}^{\infty}\frac{t^{2}}{(at+1)(t^{2}+1)}dt-\int_{0}^{\infty}\frac{t^{2}}{(at-1)(t^{2}+1)}dt$$
But, this may not be a good idea because of convergence issues.  
Does anyone have a good idea of how to approach this one?.
Thanks and take care.
 [/INST] This is a challenging integral with unexpected twists and turns in its evaluation.  Ultimately, though, it all works out.
We begin by integrating by parts, something we normally have no business doing, but the infinities cancel:
$$\int_0^{\infty} dx \frac{x}{x^2+a^2}\log{\left(\frac{x+1}{x-1}\right)} = \\ \lim_{N \rightarrow \infty}\left[\frac{1}{2} \log{(x^2+a^2)}\log{\left(\frac{x+1}{x-1}\right)}  \right]_0^N + \frac{1}{2} \int_0^{\infty} dx \log{(x^2+a^2)}\left(\frac{1}{x-1}-\frac{1}{x+1} \right)$$
Now, the limit in the first term on the RHS of the above equation converges to $-i \pi \, \log{a}$.  The second term, the integral, has a singularity about which we may deform the interval of integration; the contribution of this deformation is
$$\lim_{\epsilon \rightarrow 0} i \frac{1}{2} \epsilon \int_0^1 d\phi e^{i \phi} \frac{\log{(1+a^2)}}{\epsilon e^{i \phi}} = i \frac{\pi}{2} \log{(1+a^2)}$$  
Thus the integral is now equal to
$$PV \int_0^{\infty} dx \frac{\log{(x^2+a^2)}}{x^2-1} + i \frac{\pi}{2} \log{\left ( 1+ \frac{1}{a^2} \right )}$$
To evaluate this, let $I(a)$ be the real part of the above expression (the integral), and  differentiate $I(a)$ with respect to $a$ (which I assume is a valid step, I will not prove it here) and get
$$\frac{\partial I}{\partial a} = 2 a \, PV \int_0^{\infty} \frac{dx}{x^2+a^2} \frac{1}{x^2-1} = a PV \int_{-\infty}^{\infty} \frac{dx}{x^2+a^2} \frac{1}{x^2-1}$$
Note that this integral is equal to 
$$a \oint_C \frac{dz}{z^2+a^2} \frac{1}{z^2-1}$$
where $C$ is a semicircular arc in the upper half plane, just above the real axis (so we can ignore the poles at $z= \pm 1$, as the integral is a Cauchy principal value).  This integral is equal to $i 2 \pi$ times the sum of the residues at the poles inside $C$.  The only pole inside $C$ is at $z=ia$, so the integral is
$$a PV \int_{-\infty}^{\infty} \frac{dx}{x^2+a^2} \frac{1}{x^2-1} = a \, i 2 \pi \frac{1}{i 2 a} \frac{1}{(-a^2-1)} = -\frac{\pi}{a^2+1}$$
Integrating with respect to $a$, we find that
$$I(a) = K - \pi \arctan{a}$$
where $K$ is a constant of integration.  We determine $K$ as being equal to $I(0)$.  So the problem now reduces to evaluating
$$I(0) =2 \int_0^{\infty} dx \frac{\log{x}}{x^2-1}$$
Note that the singularity at $x=1$ is removable in this integral and therefore we do not need to use a Cauchy principal value.  We evaluate this integral by once again appealing to the residue theorem, but this time, we consider 
$$\oint_{C'} dz \frac{\log^2{z}}{z^2-1}$$
where $C'$ is a keyhole contour with respect to the positive real axis.  By integrating around this contour and noting that the integrand vanishes sufficiently fast as the radius of the circular section of $C'$ increases without bound, we get
$$\oint_{C'} dz \frac{\log^2{z}}{z^2-1} = -i 4 \pi  \int_0^{\infty} dx \frac{\log{x}}{x^2-1} + 4 \pi^2 \int_0^{\infty} dx \frac{1}{x^2-1}$$
This is equal to, by the residue theorem, $i 2 \pi$ times the sum of the residues of the poles of the integrand of the complex integral within $C'$.  As the only pole is at $z=-1$, we see that
$$\begin{align}\oint_{C'} dz \frac{\log^2{z}}{z^2-1} &= i 2 \pi \frac{\log^2{(-1)}}{2 (-1)} \\ &= i 2 \pi  \frac{\pi^2}{2}\end{align}$$ 
Now, the real part of the integral above is split into a Cauchy principal value and a piece indented about the singularity at $x=1$.  The Cauchy principal value is zero:
$$\begin{align}PV \int_0^{\infty} dx \frac{1}{x^2-1} &= \lim_{\epsilon \rightarrow 0} \left [\int_0^{1-\epsilon} dx \frac{1}{x^2-1} + \int_{1+\epsilon}^{\infty} dx \frac{1}{x^2-1}\right]\\ &= \lim_{\epsilon \rightarrow 0} \left [\int_0^{1-\epsilon} dx \frac{1}{x^2-1} + \int_0^{1/(1+\epsilon)} \left (-\frac{dx}{x^2} \right ) \frac{1}{(1/x^2)-1} \right ]\\ &= \lim_{\epsilon \rightarrow 0} \left [\int_0^{1-\epsilon} dx \frac{1}{x^2-1} - \int_0^{1-\epsilon}  \frac{dx}{x^2-1} \right ] \\ &= 0\end{align}$$
The indent in the contour, however, produces a contribution; let $x=1+\epsilon e^{i \phi}$ and $\phi \in [\pi,0]$:
$$4 \pi^2 i \epsilon \int_{-\pi}^0 d\phi \frac{e^{i \phi}}{2 \epsilon e^{i \phi}} = i \frac{\pi}{2} 4 \pi^2$$
so that
$$-i 4 \pi \int_0^{\infty} dx \frac{\log{x}}{x^2-1} = i 2 \pi \frac{\pi^2}{2} - i \frac{\pi}{2} 4 \pi^2 = -i 2 \pi \frac{\pi^2}{2}$$
Therefore
$$K = 2 \int_0^{\infty} dx \frac{\log{x}}{x^2-1} = \frac{\pi^2}{2}$$
and
$$I(a) = \frac{\pi^2}{2} - \pi \arctan{a} = \pi \left ( \frac{\pi}{2} - \arctan{a}\right ) = \pi \arctan{\frac{1}{a}}$$
and
$$\int_0^{\infty} dx \frac{x}{x^2+a^2}\log{\left(\frac{x+1}{x-1}\right)} = \pi \arctan{\frac{1}{a}}+ i \frac{\pi}{2} \log{\left ( 1+ \frac{1}{a^2} \right )}$$
Note the imaginary part, which differs from the original problem statement.  By using the absolute values, this imaginary part goes away and the stated result is true.
</s>