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

$\displaystyle \int_{0}^{\frac{\pi}{2}} \ln(\sin(x))dx=-\frac{\pi}{2}\ln(2)$ is an integral that is common.

But, how can we show $\displaystyle\int_{0}^{\frac{\pi}{2}}\ln^{2}(\sin(x))dx=\frac{{\pi}^{3}}{24}+\frac{\pi}{2}\ln^{2}(2)$?.

Does anyone have any ideas on how to approach $\displaystyle\int_{0}^{\frac{\pi}{2}}\ln^{2}(\sin(x))dx$?.

Thank you very much.

-
wolframalpha.com/input/… –  dato datuashvili Aug 20 '11 at 14:30
The elementary calculations in the answers are not complete, because the justifications of interchanging of integration and differentiation, interchanging double sums are easy but non-trivial. At least some words about it, details can be left to the reader :-) –  vesszabo Aug 29 '12 at 16:26

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.

-
ok clear i understood –  dato datuashvili Aug 20 '11 at 16:01
Could you please explain what $C$ is? –  Américo Tavares Aug 20 '11 at 16:28
I believe the C has something to do with the gamma constant, $\gamma$?. Because $psi(1/2)=-\gamma-2ln(2)$. This would then result in cancellations leaving only $\frac{{\pi}^{3}}{24}+\frac{\pi}{2}ln^{2}(2)$. Am I correct Sasha?. I like your solution. Very clever. Though, I must admit, the differentiation of the Gamma has me a little stymied. I will have to work through it. –  Cody Aug 20 '11 at 17:54
I ran through the differentiation and got: $\frac{{\pi}^{3}}{24}+\frac{\pi}{8}(\psi(1/2))^{2}+\frac{\pi \gamma}{4}\psi(1/2)+\frac{\pi {\gamma}^{2}}{8}$, which equals the correct result after simplifying. Very nice method, S. –  Cody Aug 20 '11 at 18:21
@Americo $C$ is Euler-Mascheroni constant, I edited the post to explain that. –  Sasha Aug 20 '11 at 19:39

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$.

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).

-
Actually, to add to the examples listed above, I believe one can show that $$\int_{-\pi/2}^{\pi/2}\left(\log(2\cos{x}) + ix\right)^m\,dx =0$$ for all integers $m>0$, by taking $f(z) = \log^m(1 + e^{2iz})$ and integrating instead over the rectangle with vertices $-\pi/2 + Ri$, $-\pi/2$, $\pi/2$. (Of course, the corners must be omitted as before, but this should be a nonissue.) With this choice of contour, the contributions from the vertical sides will actually cancel. –  Nick Strehlke Mar 15 '12 at 9:02
Thanks a lot Nick. That's very insightful. –  Cody Mar 19 '12 at 21:15
Genious! The pride of UCLA! –  Daniel Montealegre Mar 25 '12 at 7:29
I am pleased to report that this method can also be employed to answer the question I referenced in 2. and 3. See here. –  Nick Strehlke Mar 31 '12 at 18:15
@NickStrehlke, can I ask something? Why are you using $2ie^{iz}\sin(z)$ when it is supposed to be $\sin(z)$? –  Amad27 Dec 26 '14 at 14:36

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.

-