How to calculate $\int_0^\pi \ln(1+\sin x)\mathrm dx$

How to calculate this integral $$\int_0^\pi \ln(1+\sin x)\mathrm dx$$ I didn't find this question in the previous questions. With the help of Wolframalpha I got an answer $-\pi \ln 2+4\mathbf{G}$, where $\mathbf{G}$ denotes Catalan's Constant.


Solution 1:

First we rewrite $\log(1+\sin(x))=\log(2)+2\log(\sin(x/2+\pi/4))$. This yields, after shifting $x/2+\pi/4\rightarrow y,dx\rightarrow 2 dy$

$$ I=\pi\log(2)+4\underbrace{\int_{\pi/4}^{3\pi/4}\log(\sin(y))dy}_{J} $$

Now we might employ the Fourier series of $\log(\sin(x))$ to calculate $J$

$$ J=-\log(2)\int_{\pi/4}^{3\pi/4}dy-\sum_{n=1}^{\infty}\frac{1}{k}\int_{\pi/4}^{3\pi/4}\cos(2yk)dy=\\ -\frac{\pi}{2}\log(2)+\sum_{k=1}^{\infty}\frac{(-1)^k}{(2k+1)^2} $$

where we used $\sin(\frac{3\pi}{2} k)-\sin(\frac{\pi}{2} k)=(-1)^{k}-(-1)^{k+1}=2(-1)^k$ in the second line.

Employing the series representation of the Catalan constant we find

$$ J=-\frac{\pi}{2}\log(2)+G $$

and therefore

$$ I=\pi \log(2)+J=-\pi \log(2)+4G \quad (*) $$


Just for fun, lets see what contour integration can do. We again use $J$ rewriting it by the help of the identity $\log(\sin(x))=\log(i/2)-ix+\log(1-e^{2 i x})$. The integral over the first two terms is trivial leaving us with

$$ J=-\frac{\pi}{2}\log(2)+\underbrace{\int_{\pi/4}^{3\pi/4}\log(1-e^{2 i x})}_{K} $$

to evaluate $K$ we integrate the complex valued function

$$ f(z)=\log(1-e^{2 i z}) $$

over an rectangle $C$ in the complex plane with verticies $(\pi/4,3\pi/4,3\pi/4+i R,\pi/4+i R)$ where in the end we want to take the limit $R\rightarrow +\infty$. As one can easily check, the contribution from the top of the rectangle vanishs (the integrand vanishs as $\mathcal{O}(e^{-2R})$ for big $R$). Furthermore the integrand is holomorphic inside the contour of integration and therefore we can express the integral of interest in terms of the vertical pieces of the contour

$$ \int_C f(z)dz=K+i\int_{0}^{\infty}\log(1+ie^{-2y})dy-i\int_{0}^{\infty}\log(1-ie^{-2y})dy=0 $$

this can be simplified to

$$ K=2\int_0^{\infty}\arctan(e^{-2y})dy=\int_0^{\infty}\arctan(e^{-y})dy $$

using the series repesentation of arctan, we may easily conclude that this integral is equal to $G$ and therefore

$$ K=G $$

from which it follows that

$$ J=-\frac{\pi}{2}\log(2)+K=-\frac{\pi}{2}\log(2)+G$$

from which (*) follows immediatly