Integrate square of the log-sine integral: $\int_0^{\frac{\pi}{2}}\ln^{2}(\sin(x))dx$

Here is a completely different way to approach this integral, which relies on some elementary complex analysis (Cauchy's theorem). It is based on an approach which I have seen several times employed to compute $\int_0^{\pi/2}\log{(\sin{x})}\,dx$ (particularly, in Ahlfors's book).


The idea is to integrate the principal branch of $f(z) := \log^2{(1 - e^{2iz})} = \log^2{(-2ie^{iz}\sin{z})}$ over the contour below, and then let $R \to \infty$ and $\epsilon \to 0$.
Contour

First of all, $1 - e^{2iz} \leq 0$ only when $z = k\pi + iy$, where $k$ is integral and $y \leq 0$. Thus, in the region of the plane which is obtained by omitting the lines $\{k\pi + iy: y\leq 0\}$ for $k \in \mathbb Z$, the principal branch of $\log{(1-e^{2iz})}$ is defined and analytic. Note that, for each fixed $R$ and $\epsilon$, the contour we wish to integrate over is contained entirely within this region.

By Cauchy's theorem, the integral over the contour vanishes for each fixed $R$. Since $f(x + iR) = \log^2{(1 - e^{2ix}e^{-2R})} \to 0$ uniformly as $R \to \infty$, the integral over the segment $[iR,\pi/2 + iR]$ vanishes in the limit. Similarly, since $1 - e^{2iz} = O(z)$ as $z \to 0$, we have $f(z) = O(\log^2{|z|})$ for small enough $z$, which, since $\epsilon \log^2{\epsilon} \to 0$ with $\epsilon$, means that the the integral over the circular arc from $i\epsilon$ to $\epsilon$ vanishes as $\epsilon \to 0$.

From the vertical sides of the contour, we get the contribution $$ \begin{align*} \int_{[\pi/2,\pi/2 + iR]} + \int_{[iR,i\epsilon]} f(z)\,dz & = i\int_0^R f(\pi/2 + iy)\,dy -i\int_\epsilon^R f(iy)\,dy. \end{align*} $$ Since $f(iy)$ and $f(\pi/2 + iy)$ are real, this contribution is purely imaginary.

Finally, the contribution from the bottom side of the contour, after letting $\epsilon \to 0$, is $$ \begin{align*} \int_0^{\pi/2} f(x)\,dx = \int_0^{\pi/2} \log^2{(-2ie^{ix}\sin{x})}\,dx, \end{align*} $$ and we know from the preceding remarks that the real part of this integral must vanish. For $x$ between $0$ and $\pi/2$, the quantity $2\sin{x}$ is positive. Writing $-ie^{ix} = e^{i(x - \pi/2)}$, we see that $x - \pi/2$ is the unique value of $\arg{(-2ie^{ix}\sin{x})}$ which lies in $(-\pi,\pi)$. Since we have chosen the principal branch of $\log{z}$, it follows from these considerations that $\log{(-2ie^{ix}\sin{x})} = \log{(2\sin{x})} + i(x-\pi/2)$, and therefore that $$ \begin{align*} \text{Re}{f(x)} &= \log^2{(2\sin{x})} - (x-\pi/2)^2 \\ &= \log^2{(\sin{x})} + 2\log{2}\log{(\sin{x})} + \log^2{2} - (x - \pi/2)^2. \end{align*} $$ By setting $\int_0^{\pi/2} \text{Re}f(x)\,dx = 0$ we get $$ \begin{align*} \int_0^{\pi/2} \log^2{(\sin{x})}\,dx &= \int_0^{\pi/2}(x-\pi/2)^2\,dx - 2\log{2}\int_0^{\pi/2} \log{(\sin{x})}\,dx -\frac{\pi}{2}\log^2{2} \\ & = \frac{1}{3}\left(\frac{\pi}{2}\right)^3 + \frac{\pi}{2} \log^2{2} \end{align*} $$ as expected


By similar methods, one can compute a variety of integrals of this form with little difficulty. Here are some examples I have computed for fun. All are proved by the same method, with the same contour, but different functions $f$.

  1. Take $f(z) = \log{(1 + e^{2iz})} = \log{(2e^{iz}\cos{z})}$ and compare imaginary parts to get $$ \int_0^\infty \log{(\coth{y})}\,dy = \frac{1}{2}\left(\frac{\pi}{2}\right)^2. $$
  2. Related to this question of yours (which incidentally led me here), one can show by taking $f(z) = \log^4(1 + e^{2iz})$ and comparing real parts that $$ \int_0^{\pi/2} x^2\log^2{(2\cos{x})}\,dx = \frac{1}{30}\left(\frac{\pi}{2}\right)^5 + \frac{1}{6}\int_0^{\pi/2} \log^4{(2\cos{x})}\,dx. $$ Assuming the result of the other question, we then get $$ \int_0^{\pi/2} \log^4{(2\cos{x})}\,dx = \frac{19}{15}\left(\frac{\pi}{2}\right)^5. $$
  3. Also related to the question cited in 2., taking $f(z) = z^2\log^2{(1 + e^{2iz})}$ and comparing real parts gives $$ \int_0^{\pi/2}x^2\log^2{(2\cos{x})}\,dx = \frac{1}{5}\left(\frac{\pi}{2}\right)^5 + \pi \int_0^\infty y\log^2{(1- e^{-2y})}\,dy. $$ Once more, assuming the result of the other question, we get $$ \int_0^\infty y\log^2{(1- e^{-2y})}\,dy = \frac{1}{45}\left(\frac{\pi}{2}\right)^4. $$

Actually, the integral in 3. has several interesting series expansions, and I would be very interested if someone could compute it without using the result from the question I cited. For one thing, that would give us a different proof of that result (which is why I started investigating it in the first place).


Let $t=\sin(x)$. Then $\mathrm{d}t = \cos(x)\; \mathrm{d}x = \sqrt{1-t^2}\; \mathrm{d}x$. Now,

$$ \int_0^{\frac{\pi}{2}} \log^2(\sin(x)) \mathrm{d} x = \int_0^1 \frac{\log^2(t)}{\sqrt{1-t^2}} \mathrm{d} t $$

The latter form can be integrated by means of $\int_0^1 \frac{t^{s-1}}{\sqrt{1-t^2}} \mathrm{d} t = \frac{1}{2} \operatorname{B}\left(\frac12, \frac{s}{2}\right) = \dfrac{\sqrt{\pi}\, \Gamma\left(\frac{s}{2}\right)}{2 \Gamma\left(\frac{s+1}{2}\right)}$

Now differentiate with respect to $s$ twice and set $s=1$ which will get

$$ \frac{C^2 \pi}{8} + \frac{\pi^3}{24} + \frac{C \pi }{4} \psi\left(\frac12\right) + \frac{\pi}{8} \psi\left(\frac12\right)^2 = \frac{\pi^3}{24} + \frac{\pi}{2} \log(2)^2 $$

Added: $C$ stands for Euler-Mascheroni constant.


A third approach would be the Fourier series:

Namely, consider

$$\ln \left (2\sin \frac{x}{2}\right )=-\sum_{n=1}^{\infty}\frac{\cos nx}{n};(0<x<2\pi)$$

After squared:

$$\ln^2\left (2\sin \frac{x}{2}\right )=\sum_{n=1}^{\infty} \sum_{k=1}^{\infty}\frac{\cos kx\cos nx}{kn}$$

Now, integrate the last equation from $x=0$ to $x=\pi$

On the right side, we get:

$$\frac{\pi}{2}\sum_{k=1}^{\infty}\frac{1}{k^2}=\frac{\pi}{2}\frac{\pi^2}{6}=\frac{\pi^3}{12}$$

because $$I=\int_{0}^{\pi}\cos kx\cos nx\,dx=0;k\neq n$$ $$I=\frac{\pi}{2};k=n$$

On the left side:

$$\int_{0}^{\pi}\ln^2\left (2\sin \frac{x}{2}\right )\,dx= \ln^22 \int_{0}^{\pi}dx + 4\ln 2 \int_{0}^{\frac{\pi}{2}} \ln \left (\sin x\right )dx+2 \int_{0}^{\frac{\pi}{2}} \ln^2 \left (\sin x\right )dx $$

Since we know that $ \int_{0}^{\frac{\pi}{2}} \ln(\sin x)dx=-\frac{\pi}{2}\ln(2) $ then we get $ \int_{0}^{\frac{\pi}{2}}\ln^{2}(\sin x)dx $ from the equation.