# Evaluate the Integral $$\int_{0}^{\pi /2} \frac{x}{\sin(x)} \mathrm{d}x$$

The proof of

\int\limits_{0}^{\pi /2} \frac{x}{\sin(x)} \mathrm{d}x = 2\mathrm{G}
\tag{1}
\label{eq:xosinx-1}

where G is Catalan’s constant was part of a question at Mathematics Stack Exchange. The question could be answered without explicitly evaluating this integral, so I decided to evaluate it.

We begin by expanding the denominator in exponential functions and evaluating the following indefinite integral
\begin{align}
\int \frac{1}{\mathrm{e}^{ix}-\mathrm{e}^{-ix}} \mathrm{d}x &= -\int \frac{\mathrm{e}^{ix}}{1-\mathrm{e}^{i2x}} \mathrm{d}x \\
&= -\int \frac{\mathrm{e}^{ix}}{(1+\mathrm{e}^{ix})(1-\mathrm{e}^{ix})} \mathrm{d}x \\
&= -\frac{1}{2} \int \Big[\frac{\mathrm{e}^{ix}}{1+\mathrm{e}^{ix}} + \frac{\mathrm{e}^{ix}}{1-\mathrm{e}^{ix}} \Big] \mathrm{d}x \\
&= \frac{i}{2} \big[\ln(1+\mathrm{e}^{ix}) – \ln(1-\mathrm{e}^{ix})\big] + \mathrm{const}
\tag{2}
\label{eq:xosinx-2}
\end{align}

Now we evaluate the following integral by parts

\int \frac{x}{\mathrm{e}^{ix}-\mathrm{e}^{-ix}} \mathrm{d}x = ab \,- \int b \,\mathrm{d}a
\tag{3}
\label{eq:xosinx-3}

where $$a = x ,\, \mathrm{d}a = \mathrm{d}x ,\, \mathrm{d}b = \mathrm{d}x/(\mathrm{e}^{ix}-\mathrm{e}^{-ix}) ,\, b =$$ equation \eqref{eq:xosinx-2}.

The integral on the right in equation \eqref{eq:xosinx-3} is
\begin{align}
\int \ln(1+\mathrm{e}^{ix}) \mathrm{d}x &= i \int \frac{\ln(u)}{1-u} \mathrm{d}u \\
&= -i \int \frac{\ln(1-y)}{y} \mathrm{d}y \\
&= i \mathrm{Li}_{2}(y) \\
& = i \mathrm{Li}_{2}(-\mathrm{e}^{ix})
\tag{4}
\label{eq:xosinx-4}
\end{align}
where we used the following substitutions in succession: $$u = 1 + \mathrm{e}^{ix} ,\, y = 1-u$$. $$\mathrm{Li}_{2}(z)$$ is the dilogarithm.

Likewise, we have

\int \ln(1-\mathrm{e}^{ix}) \mathrm{d}x = i \mathrm{Li}_{2}(\mathrm{e}^{ix})
\tag{5}
\label{eq:xosinx-5}

Putting all of the pieces together, we obtain the desired result
\begin{align}
\int\limits_{0}^{\pi /2} \frac{x}{\sin(x)} \mathrm{d}x &= i2 \int\limits_{0}^{\pi /2} \frac{x}{\mathrm{e}^{ix}-\mathrm{e}^{-ix}} \mathrm{d}x \\
&= x\big[\ln(1-\mathrm{e}^{ix}) – \ln(1+\mathrm{e}^{ix}) \big] + i\Big[\mathrm{Li}_{2}(-\mathrm{e}^{ix}) – \mathrm{Li}_{2}(\mathrm{e}^{ix}) \Big] \Big|_{0}^{\pi /2} \\
&= \frac{\pi}{2} \big[\ln(1-i) – \ln(1+i) \big] + i\Big[\mathrm{Li}_{2}(-i) – \mathrm{Li}_{2}(i)\Big] – 0 -i\Big[\mathrm{Li}_{2}(-1) – \mathrm{Li}_{2}(1)\Big] \\
&= \frac{\pi}{2} \Big[\frac{\ln(2)}{2} -i\frac{\pi}{4} – \frac{\ln(2)}{2} – i\frac{\pi}{4}\Big] + i\Big[-\frac{\pi^{2}}{48}-i\mathrm{G}+\frac{\pi^{2}}{48}-i\mathrm{G} \Big] – i\Big[-\frac{\pi^{2}}{12}-\frac{\pi^{2}}{6} \Big] \\
&= 2\mathrm{G}
\end{align}