TITLE: Evaluate the definite integral $\int^{\infty }_{0}\frac{x \,dx}{e^{x} -1}$ using contour integration
QUESTION [8 upvotes]: My friend and I have been trying weeks to evaluate the integral

$$\int^{\infty }_{0}\frac{x \,dx}{e^{x} -1} .$$

We have together tried 23 contours, and all have failed.
We already know how to solve this with infinite sums (i.e., using the zeta function and the Basel problem), but we can't figure out how to solve it using contour integration methods.
We already know the answer is $\frac{\pi^{2}}{6}$.

REPLY [3 votes]: Travis has the right idea with the contour, but not quite the right auxiliary function. Instead, we use the contour $\gamma = ([0,R)\times\{0\})\cup(\{0\}\times[0,2\pi])\cup([0,R)\times\{2\pi\})\cup(\{R\}\times[0,2\pi])$ and integrate the function $f(z) = z(z-2\pi i)/(e^z-1)$ over this contour. The key is that $f(z)$ has no poles anywhere on the contour, so we don't need to worry about avoiding them to keep the integral well-defined. Since $f(z)$ also has no poles inside the contour, the integral around $\gamma$ is equal to zero. Thus,
\begin{multline}
\oint_\gamma f(z)dz = -\int_0^R \frac{x(x-2\pi i)}{e^x-1}dx + \int_0^{2\pi} \frac{(it)(it+2\pi i)}{e^{it}-1}idt \\ + \int_0^R \frac{(x+2\pi i)x}{e^{x+2\pi i}-1}dx - \int_0^{2\pi}\frac{(R+it)(R+it+2\pi i)}{e^{R+it}-1}idt = 0.
\end{multline}
It's not hard to see that the asymptotic behavior of the fourth integral is dominated by the $e^R$ in the denominator, so it will go to zero as $R\rightarrow\infty$. Noting that $e^{x+2\pi i} = e^x$, we take the that limit and do some simplification to get
$$
4\pi i\int_0^\infty \frac{x\,dx}{e^x-1} -i\int_0^{2\pi}\frac{t(t-2\pi)}{e^{it}-1}dt = 0. \Longrightarrow \int_0^\infty \frac{x\,dx}{e^x-1} = \frac{1}{4\pi}\int_0^{2\pi}\frac{t(t-2\pi)}{e^{it}-1}dt
$$
Using $(e^{it}-1)^{-1} = -[1+i\,\mathrm{cot}(t/2)]/2$ and substituting $u = t - \pi$ in the imaginary integral gives
$$\int_0^\infty \frac{x\,dx}{e^x-1} = \frac{1}{8\pi}\left[\int_0^{2\pi}t(2\pi-t)dt+i\int_{-\pi}^\pi (\pi^2-u^2)\tan\left(\frac{u}{2}\right)du\right].
$$
The $u$ integrand is clearly odd, so the integral is zero (as it has to be since the LHS is purely real). Since $\int_0^{2\pi}t(2\pi-t)dt = 4\pi^3/3$, we have
$$
\int_0^\infty \frac{x\,dx}{e^x-1} = \frac{\pi^2}{6}.
$$