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

  • $\begingroup$ wolframalpha.com/input/… $\endgroup$ – dato datuashvili Aug 20 '11 at 14:30
  • $\begingroup$ 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 :-) $\endgroup$ – 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.

  • $\begingroup$ ok clear i understood $\endgroup$ – dato datuashvili Aug 20 '11 at 16:01
  • $\begingroup$ Could you please explain what $C$ is? $\endgroup$ – Américo Tavares Aug 20 '11 at 16:28
  • $\begingroup$ 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. $\endgroup$ – Cody Aug 20 '11 at 17:54
  • $\begingroup$ 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. $\endgroup$ – Cody Aug 20 '11 at 18:21
  • $\begingroup$ @Americo $C$ is Euler-Mascheroni constant, I edited the post to explain that. $\endgroup$ – 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).

  • $\begingroup$ 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. $\endgroup$ – Nick Strehlke Mar 15 '12 at 9:02
  • $\begingroup$ Thanks a lot Nick. That's very insightful. $\endgroup$ – Cody Mar 19 '12 at 21:15
  • $\begingroup$ I am pleased to report that this method can also be employed to answer the question I referenced in 2. and 3. See here. $\endgroup$ – Nick Strehlke Mar 31 '12 at 18:15
  • $\begingroup$ @NickStrehlke, can I ask something? Why are you using $2ie^{iz}\sin(z)$ when it is supposed to be $\sin(z)$? $\endgroup$ – 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:


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.


Perform the change of variable \begin{align}y=\dfrac{\pi}{2}-x\end{align}

\begin{align}J&=\int_0^{\frac{\pi}{2}}\ln^2\left(\sin x\right) \,dx\\ &=\int_0^{\frac{\pi}{2}}\ln^2\left(\cos x\right)\,dx\\\end{align}

Consider the integrals,

\begin{align}A&=\int_0^{\frac{\pi}{2}}\ln^2\left(\tan x\right)\,dx\\ B&=\int_0^{\frac{\pi}{2}}\ln^2(\sin x\cos x)\,dx\end{align}

observe that,


Perform the change of variable \begin{align}y=\tan x\end{align}

\begin{align}A&=\int_0^\infty \frac{\ln^2 x}{1+x^2}\,dx\end{align}

Consider the double integral

\begin{align} K&=\int_0^\infty \int_0^\infty \frac{\ln^2(xy)}{(1+x^2)(1+y^2)}\,dx\,dy\\ &=2\int_0^\infty \int_0^\infty \frac{\ln^2 x}{(1+x^2)(1+y^2)}\,dx\,dy\\ &=\pi A \end{align}


\begin{align} \int_0^\infty \frac{\ln x}{1+x^2}\,dx=0\end{align}

On the other hand, perform the change of variable $u=xy$,

\begin{align}K&=\int_0^\infty \int_0^\infty \frac{y\ln^2 u}{(u^2+y^2)(1+y^2)}\,du\,dy\\\end{align}

Perform the change of variable $v=y^2$,

\begin{align}K&=\frac{1}{2}\int_0^\infty \int_0^\infty \frac{\ln^2 u}{(u^2+v)(1+v)}\,du\,dv\\ &=\frac{1}{2}\int_0^\infty\left[\frac{\ln\left(\frac{v+1}{v+u^2}\right)}{u^2-1}\right]_{v=0}^{\infty}\ln^2 u\,du\\ &=\int_0^\infty\frac{\ln^3 u}{u^2-1}\,du\\ &=\int_0^1\frac{\ln^3 u}{u^2-1}\,du+\int_1^\infty\frac{\ln^3 u}{u^2-1}\,du\\ \end{align}

In the latter integral perform the change of variable $z=\dfrac{1}{u}$,

\begin{align}K&=2\int_0^1\frac{\ln^3 u}{u^2-1}\,du\\ &=2\int_0^1\frac{\ln^3 u}{u-1}\,du-\int_0^1\frac{2u\ln^3 u}{u^2-1}\,du \end{align}

In the latter integral perform the change of variable $z=u^2$,

\begin{align}K&=\left(2-\frac{1}{8}\right)\int_0^1\frac{\ln^3 u}{u-1}\,du\\ &=-\frac{15}{8}\int_0^1\left( \sum_{n=0}^\infty u^{n}\right)\ln^3 u\,du\\ &=-\frac{15}{8}\sum_{n=0}^\infty\int_0^1 u^{n}\ln^3 u\,du\\ &=\frac{45}{4} \sum_{n=0}^\infty\frac{1}{(n+1)^4}\\ &=\frac{45}{4}\zeta(4)\\ \end{align}


\begin{align}A&=\frac{K}{\pi}\\ &=\frac{45}{4\pi}\zeta(4)\end{align}

\begin{align} B&=\int_0^{\frac{\pi}{2}}\ln^2\left(\frac{\sin(2x)}{2}\right)\,dx \end{align}

Perform the change of variable $y=2x$,

\begin{align} B&=\frac{1}{2}\int_0^{\pi}\ln^2\left(\frac{\sin x}{2}\right)\,dx\\ &=\frac{1}{2}\int_0^{\frac{\pi}{2}}\ln^2\left(\frac{\sin x}{2}\right)\,dx+\frac{1}{2}\int_{\frac{\pi}{2}}^{\pi}\ln^2\left(\frac{\sin x}{2}\right)\,dx\\ \end{align}

In the latter integral perform the change of variable $y=\pi-x$,

\begin{align} B&=\int_0^{\frac{\pi}{2}}\ln^2\left(\frac{\sin x}{2}\right)\,dx\\ &=\int_0^{\frac{\pi}{2}}\ln^2\left(\sin x\right)\,dx-2\ln 2\int_0^{\frac{\pi}{2}}\ln(\sin x)\,dx+\frac{\pi}{2}\ln^2 2\\ &=J+\frac{3\pi}{2}\ln^2 2 \end{align}


\begin{align}\frac{45}{4}\zeta(4)+J+\frac{3\pi}{2}\ln^2 2=4J \end{align}


\begin{align}J&=\frac{15}{4\pi}\zeta(4)+\frac{1}{2}\pi\ln^2 2 \end{align}

If you know that,



\begin{align}\boxed{J=\frac{\pi^3}{24}+\frac{1}{2}\pi\ln^2 2} \end{align}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.