# Evaluating $\int_0^{\large\frac{\pi}{4}} \log\left( \cos x\right) \, \mathrm{d}x$

It's my first post here and I was wondering if someone could help me with evaluating the definite integral $$\int_0^{\Large\frac{\pi}{4}} \log\left( \cos x\right) \, \mathrm{d}x$$ Thanks in advance, any help would be appreciated.

-
What did you try ? maybe putting $t=\cos(x)$ would help –  Belgi Sep 19 '12 at 12:12
There is an answer, but I cannot say how it is found: wolframalpha.com/input/?i=Integrate[Log[Cos[x]]%2C{x%2C0%2CPi%2F4}] –  Siminore Sep 19 '12 at 12:16
@Siminore: That link is broken; here's one that works. –  joriki Sep 19 '12 at 12:20
@Souvik : You mean 'evaluating'. –  mick Sep 19 '12 at 13:12

Write $$\log(\cos(x))=\log\left(\frac12 e^{ix}(1+e^{-2ix})\right)\\ =-\log 2 + ix +\sum_{k=1}^\infty\frac{(-1)^{k+1}}{k}e^{-2ikx}.$$ Then integrate term by term to obtain $$\int_0^{\pi/4}\log(\cos(x))dx=-\frac{\pi}{4}\log 2 +i\frac{\pi^2}{32}+\frac{i}{2}\sum_{k=1}^\infty\frac{(-1)^{k+1}}{k^2}\left[e^{-ik\pi/2}-1\right].$$ The odd terms of the series with $e^{-ik\pi/2}$ give rise to the Catalan constant, and the even terms combine with the other infinite series to cancel the $i\pi^2/32$ term.

-

Let $$I=\int_0^{\Large\frac\pi4}\ln(\sin x)\ dx\qquad\text{and}\qquad J=\int_0^{\Large\frac\pi4}\ln(\cos x)\ dx$$ then \begin{align} I+J&=\int_0^{\Large\frac\pi4}\ln(\sin x\cos x)\ dx\\ &=\int_0^{\Large\frac\pi4}\ln\left(\frac12\sin 2x\right)\ dx\\ &=\int_0^{\Large\frac\pi4}\ln(\sin 2x)\ dx-\int_0^{\Large\frac\pi4}\ln2\ dx\\ &=\frac12\int_0^{\Large\frac\pi2}\ln(\sin y)\ dy-\frac\pi4\ln2\qquad\color{red}{\Rightarrow}\qquad \text{set}\ y=2x\\ &=-\frac\pi2\ln2 \end{align} and \begin{align} I-J&=\int_0^{\Large\frac\pi4}\ln\left(\frac{\sin x}{\cos x}\right)\ dx\\ &=\int_0^{\Large\frac\pi4}\ln\left(\tan x\right)\ dx\\ &=\int_0^{1}\frac{\ln t}{1+t^2}\ dt\qquad\color{red}{\Rightarrow}\qquad \text{set}\ t=\tan x\\ &=\int_0^{1}\sum_{n=1}^\infty(-1)^n t^{2n}\ln t\ dt\\ &=\sum_{n=1}^\infty(-1)^n\int_0^{1} t^{2n}\ln t\ dt\\ &=-\sum_{n=1}^\infty\frac{(-1)^n}{(2n+1)^2}\\ &=-G, \end{align} where $G$ is Catalan's constant. Therefore $$I=\int_0^{\Large\frac\pi4}\ln(\sin x)\ dx=-\frac12\left(G+\frac\pi2\ln2\right)$$ and $$J=\int_0^{\Large\frac\pi4}\ln(\cos x)\ dx=\frac12\left(G-\frac\pi2\ln2\right).$$

References :

$[1]\ \ \displaystyle\int_0^{\Large\frac\pi2}\ln(\sin y)\ dy=\int_0^{\Large\frac\pi2}\ln(\cos y)\ dy=-\frac\pi2\ln2$

$[2]\ \ \displaystyle\int_0^1 x^\alpha \ln^k x\ dx=\frac{(-1)^k k!}{(\alpha+1)^{k+1}}, \qquad\text{for }\ k=0,1,2,\ldots$

-
The $n$-index in the Catalan constant must start at $\ \color{#c00000}{0}\$ instead of 1. You can check it at this link. –  Felix Marin Dec 28 '14 at 6:03


-

The integral: $$S=\int_0^\frac{\pi}{4}\log(\cos(x))dx=\frac{1}{4}(2C-\pi \log 2)$$ where $C$ is the Catalan constant.

-
So Wolfram|Alpha tells us. Can you offer any insight into how this result is obtained? –  joriki Sep 19 '12 at 12:22
Hmhm, I saw that answer with Catalan constant,can there be a more elementary solution without infinite series? –  Souvik Sep 19 '12 at 12:26
Use $\cos(x)=\frac{\exp(i\theta)+\exp(-i\theta)}{2}$ and then integrate it. –  Riccardo.Alestra Sep 19 '12 at 12:33
The reason the Catalan constant has a special name is that it cannot (as far as we know) be written in terms of more familiar things. –  GEdgar Sep 19 '12 at 13:07
@ Riccardo: This helps us to find the part with $\pi log(2)$ but how do you find the Catalan constant with that ? –  mick Sep 19 '12 at 13:16