Evaluate $\int_0^{{\pi}/{2}} \log(1+\cos x)\, dx$
Solution 1:
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\pi2}\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-\sum_{k=0}^{\infty} \frac{(-1)^k}{(2 k+1)^2}\\ &=\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\pi2}\ln(1+\cos x)\ dx =\large\color{blue}{2\text{G}-\frac{\pi}{2}\ln2}. \end{align}
Solution 2:
Here is a formula I find quite useful:
$$
\begin{align}
\log(1+\cos(x))
&=\log\left(\frac{e^{ix}+2+e^{-ix}}{2}\right)\tag{1}\\
&=2\log\left(e^{ix/2}+e^{-ix/2}\right)-\log(2)\tag{2}\\
&=2\left[ix/2+\log\left(1+e^{-ix}\right)\right]-\log(2)\tag{3}\\
&=2\left[-ix/2+\log\left(1+e^{ix}\right)\right]-\log(2)\tag{4}\\
&=\log\left(1+e^{ix}\right)+\log\left(1+e^{-ix}\right)-\log(2)\tag{5}\\
&=\sum_{k=1}^\infty(-1)^{k-1}\frac{e^{ikx}}{k}+\sum_{k=1}^\infty(-1)^{k-1}\frac{e^{-ikx}}{k}-\log(2)\tag{6}\\
&=2\sum_{k=1}^\infty(-1)^{k-1}\frac{\cos(kx)}{k}-\log(2)\tag{7}
\end{align}
$$
Explanation:
$(1)$: $\cos(x)=\frac{e^{ix}+e^{-ix}}{2}$
$(2)$: pull out the $\log(2)$ and use $\left(e^{ix/2}+e^{-ix/2}\right)^2=e^{ix}+2+e^{-ix}$
$(3)$: pull $e^{ix/2}$ out of $\log\left(e^{ix/2}+e^{-ix/2}\right)$ in $(2)$
$(4)$: pull $e^{-ix/2}$ out of $\log\left(e^{ix/2}+e^{-ix/2}\right)$ in $(2)$
$(5)$: average $(3)$ and $(4)$
$(6)$: use the power series for $\log(1+x)$
$(7)$: $\cos(x)=\frac{e^{ix}+e^{-ix}}{2}$
Apply the formula above to the integral in the question: $$ \begin{align} \int_0^{\pi/2}\log(1+\cos(x))\,\mathrm{d}x &=2\sum_{k=1}^\infty\frac{(-1)^{k-1}}{k}\int_0^{\pi/2}\cos(kx)\,\mathrm{d}x-\frac\pi2\log(2)\\ &=2\sum_{k=1}^\infty\frac{(-1)^{k-1}}{k^2}\sin(k\pi/2)-\frac\pi2\log(2)\\ &=2\sum_{n=0}^\infty\frac{(-1)^n}{(2n+1)^2}-\frac\pi2\log(2)\\ &=2\mathrm{G}-\frac\pi2\log(2)\tag{8} \end{align} $$ where $\mathrm{G}$ is Catalan's constant.
Solution 3:
hint: $$\int\ln[1+\cos(x)]dx=\int\ln\left[2\cos^2\left(\frac{x}{2}\right)\right]dx\\=\int\ln(2)dx+\int\ln\left[\cos^2\left(\frac{x}{2}\right)\right]dx\\=\ln(2)\int dx+2\int\ln\left[\cos\left(\frac{x}{2}\right)\right]dx\\=\ln(2)\int dx+4\int\ln\cos(t)dt\bigg|_{t=x/2}$$ then you can use your helpful integration to have the result.
Solution 4:
\begin{align}
\color{red}{\int^{\pi/2}_0\log(1+\cos{x}){\rm d}x}
&=\int^{\pi/2}_0\frac{x\sin{x}}{1+\cos{x}}{\rm d}x\tag1\\
&=\int^{\pi/2}_0 x\tan{\frac{x}{2}} \ {\rm d}x\tag2\\
&=4\int^{\pi/4}_0x\tan{x} \ {\rm d}x\tag3\\
&=8\sum^\infty_{n=1}(-1)^{n-1}\int^{\pi/4}_0x\sin(2nx) \ {\rm d}x\tag4\\
&=2\sum^\infty_{n=1}(-1)^{n-1}\frac{\sin\left(\frac{n\pi}{2}\right)}{n^2}-\pi\sum^\infty_{n=1}(-1)^{n-1}\frac{\cos\left(\frac{n\pi}{2}\right)}{n}\\
&=2\sum^\infty_{n=0}\frac{\sin\left(\frac{(2n+1)\pi}{2}\right)}{(2n+1)^2}-\color{grey}{2\sum^\infty_{n=1}\frac{\sin\left(n\pi\right)}{4n^2}}\\
&-\color{grey}{\pi\sum^\infty_{n=0}\frac{\cos\left(\frac{(2n+1)\pi}{2}\right)}{2n+1}}+\pi\sum^\infty_{n=1}\frac{\cos\left(n\pi\right)}{2n}\tag5\\
&=2\sum^\infty_{n=0}\frac{(-1)^n}{(2n+1)^2}+\frac{\pi}{2}\sum^\infty_{n=1}\frac{(-1)^n}{n}\tag6\\
&\large{\color{red}{=2G-\frac{\pi}{2}\log{2}}}\tag7\\
\end{align}
Explanation:
$(1)$: Integrate by parts
$(2)$: Trigonometric identities
$(3)$: Substitute $x\mapsto \frac{x}{2}$
$(4)$: Use the Fourier series of $\tan{x}$
$(5)$: Split the sum into odd and even terms. It is obvious that the grey sums $=0$
$(6)$: $\sin\left(\frac{(2n+1)\pi}{2}\right)=\cos{n\pi}=(-1)^n$ for integer $n$. This can be verified easily.
$(7)$: The first sum is Catalan's constant. The second is $-\log(1+1)$. (Taylor's series)
Solution 5:
Let's try your way. Put $1+\cos x=2\cos^2\frac x2$ and use substitution $\frac x2\mapsto x$, we get \begin{equation} \int_0^{{\pi}/{2}} \log(1+\cos x)\ dx=\int_0^{{\pi}/{2}} \log2\ dx +4\int_0^{{\pi}/{4}} \log \cos x\ dx \end{equation} The first integral is a piece of cake and the second integral has been evaluated here. The final result is \begin{equation} \int_0^{{\pi}/{2}} \log(1+\cos x)\ dx=\frac{\pi}{2} \log2 +4\left(\frac C2-\frac{\pi}{4} \log2\right)=2C-\frac{\pi}{2} \log2 \end{equation}