# Evaluate the Integral $$\int \frac{x}{e^{x}-1} \mathrm{d}x$$

How to evaluate

\int \frac{x}{e^{x}-1} \mathrm{d}x
\tag{1}
\label{eq:161007-1}

was a question posed at Mathematics Stack Exchange.

Here is my solution.

Begin with

I_{1} = \int \frac{1}{e^{x}-1} \mathrm{d}x = \int \frac{e^{-x}}{1-e^{-x}} \mathrm{d}x = \ln(1-e^{-x})
\tag{2}
\label{eq:161007-2}

and rewrite our result as
\begin{align}
\ln(1-e^{-x}) &= \ln[-e^{-x}(-e^{-x}+1)] \\
&= \ln(-1) + \ln(e^{-x}) + \ln(1-e^{x}) \\
&= i\pi \,- x + \ln(1-e^{x})
\end{align}
and thus

I_{1} = i\pi \,- x + \ln(1-e^{x})

Now we evaluate equation \eqref{eq:161007-1}, our original integral, via integration by parts. For $$\int a\mathrm{d}b = ab – \,\int b\mathrm{d}a$$ we have $$a = x$$, $$\mathrm{d}b = (e^{x}-1)^{-1}$$, and $$b = I_{1}$$

\int \frac{x}{e^{x}-1} \mathrm{d}x = x I_{1} \,- \int I_{1} \mathrm{d}x

\int I_{1} \mathrm{d}x = \int [i\pi \,- x + \ln(1-e^{x})] \mathrm{d}x = i\pi x \,- \frac{1}{2}x^{2} + \int \ln(1-e^{x}) \mathrm{d}x

For the integral on the right hand side, we make the substitution $$y = e^{x}$$,

\int \ln(1-e^{x}) \mathrm{d}x = \int \frac{\ln(1-y)}{y} \mathrm{d}y = -\mathrm{Li}_{2}(y) = -\mathrm{Li}_{2}(e^{x})

Putting all of the pieces together, we have
\begin{align}
\int \frac{x}{e^{x}-1} \mathrm{d}x &= i\pi x \,- x^{2} + x\ln(1-e^{x}) – \left(i\pi x \,- \frac{1}{2}x^{2} -\mathrm{Li}_{2}(e^{x}) \right) \\
&= \mathrm{Li}_{2}(e^{x}) + x\ln(1-e^{x}) \,- \frac{1}{2}x^{2} + \mathrm{const}
\end{align}