Evaluating $\int_0^\infty \left( \frac{x}{e^x-e^{-x}}-\frac{1}{2} \right) \frac{dx}{x^2}$

Evaluating $$\int_0^\infty \left( \frac{x}{e^x-e^{-x}}-\frac{1}{2} \right) \frac{dx}{x^2}$$

I tried to calculate it by Mathematica, but it failed to give me an answer.

Then I got interested in this problem because it actually can be well evaluated.

My attempt

Put $$g(x)=\frac{1}{x}\left(\frac{1}{e^x-1}-\frac{1}{x}+\frac{1}{2}e^{-x}\right)$$

Considering that $$\left( \frac{x}{e^x-e^{-x}}-\frac{1}{2} \right) \frac{1}{x^2} = -\frac{1}{2x}\left(e^{-x}-e^{-2x}\right) + g(x)-2g(2x)$$

and $$\int_0^\infty g(x) dx = 2 \int_0^\infty g(2x) dx$$

thus via Frullani's integral we have $$\int_0^\infty \left( \frac{x}{e^x-e^{-x}}-\frac{1}{2} \right) \frac{dx}{x^2} = -\frac{1}{2} \int_0^\infty \frac{1}{x}\left(e^{-x}-e^{-2x}\right) =-\frac{1}{2} \log 2$$

But I am looking forward to other approaches, beacuse this method doesn't seem quite natural. And I would highly appreciate it if you could share any thoughts on how to solve this problem. Thanks in advance!

This integral is $$\frac{1}{4}\int_{-\infty}^\infty \frac{x\,\mathrm{csch}(x)-1}{x^2}dx$$ This function is analytic on $$\mathbb R$$, but $$\mathrm{csch}$$ still has an infinite number of poles in $$\mathbb C$$ at $$i\pi \mathbb Z$$. The residue at each of these poles is $$(-1)^n/(in\pi)$$, so doing the standard contour around the upper half-plane gives $$\frac{1}{4}\int_{-\infty}^\infty \frac{x\,\mathrm{csch}(x)-1}{x^2}dx = \frac{2\pi i}{4}\sum_{n=1}^\infty\frac{(-1)^n}{in\pi} = \frac{1}{2}\sum_{n=1}^\infty \frac{(-1)^n}{n} = -\frac{1}{2}\ln(2).$$ (This is admittedly trickier than I made it out to be as the error estimates on the contour need to be done more carefully than the usual case, but it's not too hard to work out.)
• It seems to me that you need to be a bit careful in showing that the integral over the semicircle of large radius is $0$ in the limit. What if you accidentally pick a large radius that passes near (or, worse, through) one of the poles? – Barry Cipra May 12 at 6:14
• @BarryCipra You treat it as the limit of a sequence of contours of radius $(n+1/2)\pi$ to avoid going through a pole. The bigger issue that I glossed over is you need to make separate error estimates near the imaginary axis because the integrand only decays as $1/r$ there. – eyeballfrog May 12 at 6:18