## Evaluate the Integral $$\int_{0}^{1} \tan^{-1}(\mathrm{e}^{x}) \mathrm{d}x$$

How to evaluate

I = \int\limits_{0}^{1} \tan^{-1}(\mathrm{e}^{x}) \mathrm{d}x

was a question posed at Mathematics Stack Exchange.

Here is my solution. We express the inverse tangent as logarithms:

\tan^{-1}(z) = \frac{i}{2} [\ln(1-iz) – \ln(1+iz)]

thus our integral becomes
\begin{align}
I &= \frac{i}{2} \int\limits_{0}^{1} \left(\ln(1-i\mathrm{e}^{x}) – \ln(1+i\mathrm{e}^{x}) \right) \mathrm{d}x \\
&= \frac{i}{2} (I_{1} + I_{2})
\end{align}

To evaluate $$I_{1}$$ we make the substitution $$z = i\mathrm{e}^{x}$$
\begin{align}
I_{1} &= \int\limits_{0}^{1} \ln(1-ie^{x}) \mathrm{d}x \\
&= \int\limits_{i}^{i\mathrm{e}} \frac{\ln(1-z)}{z} \mathrm{d}z \\
&= \int\limits_{0}^{i\mathrm{e}} \frac{\ln(1-z)}{z} \mathrm{d}z – \int\limits_{0}^{i} \frac{\ln(1-z)}{z} \mathrm{d}z\\
&= \mathrm{Li}_{2}(i) – \mathrm{Li}_{2}(i\mathrm{e}) \\
&= i\mathrm{G} – \frac{\pi^{2}}{48} – \mathrm{Li}_{2}(i\mathrm{e})
\end{align}

To evaluate $$I_{2}$$ we make the substitution $$-z = i\mathrm{e}^{x}$$
\begin{align}
I_{2} &= \int\limits_{0}^{1} \ln(1+ie^{x}) \mathrm{d}x \\
&= \int\limits_{-i}^{-i\mathrm{e}} \frac{\ln(1-z)}{z} \mathrm{d}z \\
&= \int\limits_{0}^{-i\mathrm{e}} \frac{\ln(1-z)}{z} \mathrm{d}z – \int\limits_{0}^{-i} \frac{\ln(1-z)}{z} \mathrm{d}z\\
&= \mathrm{Li}_{2}(-i\mathrm{e}) – \mathrm{Li}_{2}(-i) \\
&= \mathrm{Li}_{2}(-i\mathrm{e}) – \left(-i\mathrm{G} – \frac{\pi^{2}}{48} \right)
\end{align}

Putting the pieces together, we obtain our final result
\begin{align}
I &= \frac{i}{2} (I_{1} + I_{2}) \\
&= \frac{i}{2} [\mathrm{Li}_{2}(-i\mathrm{e}) – \mathrm{Li}_{2}(i\mathrm{e})] – \mathrm{G} \\
&= \int\limits_{0}^{1} \tan^{-1}(\mathrm{e}^{x}) \mathrm{d}x
\end{align}

Notes:

1. $$\mathrm{G}$$ is Catalan’s constant.
2. Expressions for $$\mathrm{Li}_{2}(\pm i)$$ can be found here.

## 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}