How to find $\int_{0}^{\pi/2} \log ({1+\cos x}) dx$ using real-variable methods?
How do you find the value of this integral, using real methods?
$$I=\displaystyle\int_{0}^{\pi/2} \log ({1+\cos x}) dx$$
The answer is $2C-\dfrac{\pi}{2}\log {2}$ where $C$ is Catalan's constant.
Solution 1:
By using $\cos(x)=\frac{1-\tan^2(x/2)}{1+\tan^2(x/2)}$ we have: $$\begin{eqnarray*} I = 2\int_{0}^{1}\frac{\log 2-\log(1+t^2)}{1+t^2}dt&=&2\int_{0}^{1}\frac{\log 2-\log t-\log(1/t+t)}{1+t^2}dt\\&=&2I_1-2I_2-2I_3,\end{eqnarray*}$$ where: $$I_1=\int_{0}^{1}\frac{\log 2}{1+t^2}\,dt = \frac{\pi}{4}\log 2,$$ $$I_2=\int_{0}^{1}\frac{\log t}{1+t^2}\,dt = \sum_{k=0}^{+\infty}(-1)^k\int_{0}^{1}t^{2k}\log t\,dt = -C,$$ $$I_3=\int_{0}^{1}\frac{\log(t+1/t)}{t^2+1}\,dt=\int_{1}^{+\infty}\frac{\log u}{u\sqrt{u^2-1}}\,du=\int_{0}^{1}\frac{-\log\nu}{\sqrt{1-\nu^2}}\,d\nu,$$ $$ I_3=-\int_{0}^{\pi/2}\log\cos t\,dt=\frac{\pi}{2}\log 2,$$ hence:
$$ I = 2C-\frac{\pi}{2}\log 2.$$
Solution 2:
If you don't mind, this is another solution that is more simplistic. Integrating by parts gives \begin{align} I &=\int^{\pi/2}_0\ln(1+\cos{x})dx\\ &=\int^{\pi/2}_0\frac{x\sin{x}}{1+\cos{x}}dx\\ &=\int^{\pi/2}_0\frac{x\tan{x}}{\sec{x}+1}\frac{\sec{x}-1}{\sec{x}-1}dx\\ &=\underbrace{\int^{\pi/2}_0\frac{x}{\sin{x}}dx}_{2G}-\int^{\pi/2}_0\frac{x}{\tan{x}}dx\\ &=2G-\int^{\pi/2}_0x\cot{x}dx\\ &=2G+\int^{\pi/2}_0\ln\sin{x}dx\\ &=2G-\frac{\pi}{2}\ln{2} \end{align}
Solution 3:
Using Weierstrass substitution $$ t=\tan\frac x2\qquad;\qquad\cos x=\frac{1-t^2}{1+t^2}\qquad;\qquad dx=\frac{2}{1+t^2}\ dt $$ we obtain \begin{align} \int_0^{\Large\frac\pi4}\ln(1+\cos x)\ dx&=2\underbrace{\int_0^1\frac{\ln2}{1+t^2}\ dt}_{\color{blue}{\text{set}\ t=\tan\theta}}-2\color{red}{\int_0^1\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt}\\ &=\frac{\pi}{2}\ln2-2\color{red}{\int_0^1\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt}.\tag1 \end{align} Consider \begin{align} \int_0^\infty\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt&=\int_0^1\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt+\underbrace{\int_1^\infty\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt}_{\large\color{blue}{t\ \mapsto\ \frac1t}}\\ &=2\int_0^1\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt-2\int_0^1\frac{\ln t}{1+t^2}\ dt\\ \color{red}{\int_0^1\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt}&=\frac12\underbrace{\int_0^\infty\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt}_{\color{blue}{\text{set}\ t=\tan\theta}}+\int_0^1\frac{\ln t}{1+t^2}\ dt\\ &=-\underbrace{\int_0^{\Large\frac\pi2}\ln\cos\theta\ d\theta}_{\color{blue}{\Large\text{*}}}+\sum_{k=0}^\infty(-1)^k\underbrace{\int_0^1 t^{2k}\ln t\ dt}_{\color{blue}{\Large\text{**}}}\\ &=\frac\pi2\ln2-\text{G},\tag2 \end{align} where $\text{G}$ is Catalan's constant.
$(*)$ can be proven by using the symmetry of $\ln\cos\theta$ and $\ln\sin\theta$ in the interval $\left[0,\frac\pi2\right]$ and $(**)$ can be proven by using formula $$ \int_0^1 x^\alpha \ln^n x\ dx=\frac{(-1)^n n!}{(\alpha+1)^{n+1}}, \qquad\text{for }\ n=0,1,2,\ldots $$ Thus, plugging in $(2)$ to $(1)$ yields \begin{align} \int_0^{\Large\frac\pi4}\ln(1+\cos x)\ dx =\large\color{blue}{2\text{G}-\frac{\pi}{2}\ln2}.\tag{Q.E.D.} \end{align}