Integral $\int_0^\infty \log(1+x^2)\frac{\cosh{\frac{\pi x}{2}}}{\sinh^2{\frac{\pi x}{2}}}\mathrm dx=2-\frac{4}{\pi}$
Hi I am trying to show$$ I:=\int_0^\infty \log(1+x^2)\frac{\cosh{\frac{\pi x}{2}}}{\sinh^2{\frac{\pi x}{2}}}\mathrm dx=2-\frac{4}{\pi}. $$ Thank you. What a desirable thing to want to prove! It is a work of art this one. I wish to prove this in as many ways as we can find.
Note I tried writing $$ I=\int_0^\infty \log(1+x^2)\coth \frac{\pi x}{2} \sinh^{-2} \frac{\pi x}{2}\mathrm dx $$ but this didn't help me much. We can also try introducing a parameter as follows $$ I(\alpha)=\int_0^\infty \log(1+x^2)\frac{\cosh{\frac{\alpha \pi x}{2}}}{\sinh^2{\frac{\pi x}{2}}}\mathrm dx, $$ But this is where I got stuck. How can we calculate I? Thanks.
As Lucian stated in the comments, integrating by parts shows that the integral is equivalent to showing that $$ \int_{0}^{\infty} \frac{x}{1+x^{2}} \frac{1}{\sinh \frac{\pi x}{2}} \ dx = \frac{\pi}{2}-1 .$$
Let $ \displaystyle f(z) = \frac{z}{1+z^{2}} \frac{1}{\sinh \frac{\pi z}{2}} $ and integrate around a rectangle with vertices at $\pm N$ and $\pm N+ i (2N+1)$ where $N$ is some positive integer.
As $N$ goes to infinity through the integers, the integral vanishes on the left and right sides of the rectangle and along the top of the rectangle.
In particular, the absolute value of the integral along the top of the rectangle is bounded by $$\frac{3N+1}{(2N+1)^{2}-1}\int_{-\infty}^{\infty} \frac{1}{\cosh \frac{\pi x}{2}} \ dx = \frac{6N+2}{(2N+1)^{2}-1} \to 0 \ \text{as} \ N \to \infty .$$
Then
$$\int_{-\infty}^{\infty} \frac{x}{1+x^{2}} \frac{1}{\sinh \frac{\pi x}{2}} \ dx = 2 \pi i \left(\text{Res}[f(z),i]+ \sum_{k=1}^{\infty} \text{Res}[f(z),2ki] \right)$$
where
$$ \text{Res}[f(z),i] = \lim_{z \to i} \frac{z}{z+i} \frac{1}{\sinh \frac{\pi x}{2}} =\frac{1}{2i}$$
and
$$ \text{Res}[f(z),2ki] = \lim_{z \to 2ki} \frac{z}{2z \sinh \frac{\pi z}{2}+(1+z^{2}) \frac{\pi}{2} \cosh \frac{\pi z}{2}} = \frac{4i}{\pi} \frac{(-1)^{k} k}{1-4k^{2}} . $$
And notice that
$$ \begin{align} \sum_{k=1}^{\infty} \frac{(-1)^{k} k}{1-4k^{2}} &= -\frac{1}{4} \sum_{k=1}^{\infty} \left( \frac{(-1)^{k}}{2k+1} + \frac{(-1)^{k}}{2k-1} \right) \\ &= -\frac{1}{4} \left(\arctan(1)-1 - \arctan(1) \right) \\ &= \frac{1}{4} . \end{align}$$
Therefore,
$$ \int_{-\infty}^{\infty} \frac{x}{1+x^{2}} \frac{1}{\sinh \frac{\pi x}{2}} \ dx = 2 \pi i \left(\frac{1}{2i} + \frac{i}{\pi} \right) = \pi - 2$$
which implies
$$ \int_{0}^{\infty} \frac{x}{1+x^{2}} \frac{1}{\sinh \frac{\pi x}{2}} \ dx = \frac{\pi}{2} -1 .$$
I will solve the general form
\begin{align}\int^\infty_0\frac{x}{x^2+1}\frac{dx}{\sinh(ax)}&=\int^\infty_0\frac{x}{x^2+a^2}\frac{dx}{\sinh(x)} \\&=\int^\infty_0 \int^\infty_0e^{-at} \frac{\sin(xt)}{\sinh(x)}\,dt \, dx\\&=\int^\infty_0 e^{-at}\int^\infty_0 \frac{\sin(xt)}{\sinh(x)} \, dx\,dt \\&=\frac{\pi}{2} \int^\infty_0 e^{-at}\tanh\left(\frac{\pi}{2} t\right)\,dt\\&=\int^\infty_0 e^{-zx}\tanh(x)\,dt \,\,\,\,; z=\frac{2}{\pi}a\\&=\int^\infty_0\frac{e^{-zx}(1-e^{-2x})}{e^{-2x}+1}\,dx\end{align}
By splitting the integral we have
\begin{align} \int^\infty_0\frac{e^{-zx}}{e^{-2x}+1}\,dx &= \sum_{n\geq 0}\int^\infty_0e^{-x(2n+z)}\,dx\\&=\sum_{n\geq 0}\frac{(-1)^n}{2n+z}\\&=\frac{1}{4}\left (\psi \left(\frac{1}{2}+\frac{z}{4}\right)-\psi \left(\frac{z}{4} \right) \right)\end{align}
\begin{align}-\int^\infty_0\frac{-e^{-x(z+2)}}{e^{-2x}+1}\,dx&=-\sum_{n\geq0}\frac{(-1)^n}{z+2+2n}\\&=-\frac{1}{4}\left(-\psi \left(\frac{1}{2}+\frac{z}{4}\right)+\psi\left(1+\frac{z}{4} \right) \right)\end{align}
Hence we have
\begin{align}\int^\infty_0\frac{x}{x^2+1}\frac{dx}{\sinh(ax)}&=\frac{1}{4}\left (2\psi \left(\frac{1}{2}+\frac{z}{4}\right)-\psi \left(1+\frac{z}{4}\right)-\psi \left(\frac{z}{4} \right) \right)\\&=\frac{1}{2}\psi \left(\frac{1}{2}+\frac{z}{4}\right)-\frac{1}{2}\psi \left(\frac{z}{4} \right)-z \\&=\frac{1}{2}\psi \left(\frac{1}{2}+\frac{a}{2\pi}\right)-\frac{1}{2}\psi \left(\frac{a}{2\pi} \right)-\frac{2}{\pi}a \end{align}
Let $a=\pi/2$
\begin{align}\int^\infty_0\frac{x}{x^2+1}\frac{dx}{\sinh(\frac{\pi}{2}x)}&=\frac{1}{2}\psi \left(\frac{1}{2}+\frac{1}{4}\right)-\frac{1}{2}\psi \left(\frac{1}{4} \right)-1\\&=\frac{\pi}{2} \cot(\pi/4)-1\\&=\frac{\pi}{2}-1\end{align}
You can also use Fourier methods here, just as was done here, beginning from the form discussed above derived after an integration by parts. Note that
$$\int_{-\infty}^{\infty} dx \, x \operatorname{csch}{(\pi x/2)} \, e^{i k x} = 2 \operatorname{sech^2}{\left ( k \right )} $$
Therefore, Parseval's equality implies that
$$I = \frac1{2 \pi} \int_0^{\infty} dk \, \pi \, e^{-k} 2 \operatorname{sech^2}{\left ( k \right )} $$
Integrate by parts to get that
$$I = \int_0^{\infty} dk \, e^{-k} \, \tanh{k} = \int_0^{\infty} dk \, e^{-k} \frac{1-e^{-2k}}{1+e^{-2k}}$$
Expand the denominator to evaluate the integral in terms of a sum:
$$I = \sum_{n=0}^{\infty} (-1)^n \int_0^{\infty} dk \, \left (e^{-(2 n+1) k}-e^{-(2 n+3) k} \right ) = \sum_{n=0}^{\infty} (-1)^n \left (\frac1{2 n+1}-\frac1{2 n+3} \right ) \\ = \frac{\pi}{4} - \left ( 1-\frac{\pi}{4} \right ) = \frac{\pi}{2}-1$$
as was to be shown.
ADDENDUM
It's only fair that I at least outline a proof of the first equation. In fact, one uses symmetry to rewrite the integral as
$$\int_{-\infty}^{\infty} dx \, x \operatorname{csch}{(\pi x/2)} \, e^{i k x} = 2 \operatorname{Re}{\left [\int_0^{\infty} dx \, x \operatorname{csch}{(\pi x/2)} \, e^{i k x} \right ]} $$
Then use the definition of csch to turn the integral into a sum equal to
$$4 \sum_{n=0}^{\infty} \frac{\pi^2 (n+1/2)^2 - k^2}{[\pi^2 (n+1/2)^2 + k^2]^2} = \frac{2}{\pi^2} \sum_{n=-\infty}^{\infty} \frac{ (n+1/2)^2 - k^2/\pi^2}{[(n+1/2)^2 + k^2/\pi^2]^2}$$
The sum on the RHS may be evaluated using the Residue theorem; the sum is then equal to
$$-\frac{2}{\pi} \sum_{\pm} \left [\frac{d}{dz} \frac{[(z+1/2)^2-k^2/\pi^2] \cot{\pi z}}{(z+1/2\pm i k/\pi)^2} \right ]_{z=-\frac12 \pm i \frac{k}{\pi}} $$
which leads to the stated result.