# 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 Commented Sep 19, 2012 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}] Commented Sep 19, 2012 at 12:16
• @Siminore: That link is broken; here's one that works. Commented Sep 19, 2012 at 12:20
• @Souvik : You mean 'evaluating'.
– mick
Commented Sep 19, 2012 at 13:12

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=0}^\infty(-1)^n t^{2n}\ln t\ dt\\ &=\sum_{n=0}^\infty(-1)^n\int_0^{1} t^{2n}\ln t\ dt\\ &=-\sum_{n=0}^\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. Commented Dec 28, 2014 at 6:03
• very very very nice! (+1) Commented Nov 11, 2018 at 20:38

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.

$\newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle} \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack} \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,} \newcommand{\dd}{{\rm d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\dsc}[1]{\displaystyle{\color{red}{#1}}} \newcommand{\expo}[1]{\,{\rm e}^{#1}\,} \newcommand{\fermi}{\,{\rm f}} \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,} \newcommand{\half}{{1 \over 2}} \newcommand{\ic}{{\rm i}} \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow} \newcommand{\Li}[1]{\,{\rm Li}_{#1}} \newcommand{\norm}[1]{\left\vert\left\vert\, #1\,\right\vert\right\vert} \newcommand{\pars}[1]{\left(\, #1 \,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}} \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,} \newcommand{\sech}{\,{\rm sech}} \newcommand{\sgn}{\,{\rm sgn}} \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}} \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$

\begin{align}&\color{#66f}{\large\int_{0}^{\pi/4}\ln\pars{\cos\pars{x}}\,\dd x} = \int_{-\pi/2}^{-\pi/4}\ln\pars{-\sin\pars{x}}\,\dd x = \int_{\pi/4}^{\pi/2}\ln\pars{\sin\pars{x}}\,\dd x \\[5mm]&=\int_{\pi/4}^{\pi/2}\overbrace{\bracks{% -\ln\pars{2} - \sum_{k\ =\ 1}^{\infty}{\cos\pars{2kx} \over k}}}^{\dsc{\ln\pars{\sin\pars{x}}}}\,\dd x =-\,{1 \over 4}\,\pi\ln\pars{2} -\sum_{k\ =\ 1}^{\infty}{1 \over k}\int_{\pi/4}^{\pi/2}\cos\pars{2kx}\,\dd x \\[5mm]&=-\,{1 \over 4}\,\pi\ln\pars{2} -\sum_{k\ =\ 1}^{\infty}{1 \over k}{\sin\pars{k\pi} - \sin\pars{k\pi/2} \over 2k} =-\,{1 \over 4}\,\pi\ln\pars{2} +\half\sum_{k\ =\ 1}^{\infty}{\sin\pars{k\pi/2} \over k^{2}} \\[5mm]&=-\,{1 \over 4}\,\pi\ln\pars{2} +\half\sum_{k\ =\ 0}^{\infty}{\sin\pars{k\pi + \pi/2} \over \pars{2k + 1}^{2}} =-\,{1 \over 4}\,\pi\ln\pars{2} +\half\ \underbrace{\sum_{k\ =\ 0}^{\infty}{\pars{-1}^{k} \over \pars{2k + 1}^{2}}} _{\ds{\mbox{Catalan Constant}\ \dsc{G}}} \\[5mm]&=\color{#66f}{\large-\,{1 \over 4}\,\pi\ln\pars{2} + \half\,G} \end{align}

• Could you explain $$-\sum_{k\geq1}\frac{\sin(\pi k)-\sin(\pi k/2)}{k^2}=\sum_{k\geq1}\frac{\sin(\pi k/2)}{k^2}$$ Commented Nov 11, 2018 at 20:42
• Wait never-mind I feel like an idiot. $$\forall k\in\Bbb Z, \sin(\pi k)=0$$ Commented Nov 11, 2018 at 20:45

By the Fourier series of ln(cos x (https://math.stackexchange.com/a/1070809/732917)), we have \begin{aligned}\ln (\cos x) &=-\ln 2+\sum_{n=0}^{\infty} \frac{(-1)^{n+1}}{n} \cos (2 n x) \\\int_{0}^{\frac{\pi}{4}} \ln (\cos x) d x &=-\frac{\pi}{4} \ln 2+\sum_{n=0}^{\infty} \frac{(-1)^{n+1}}{n} \int_{0}^{\frac{\pi}{4}} \cos 2 n x d x \\&=-\frac{\pi}{4} \ln 2+\sum_{n=0}^{\infty} \frac{(-1)^{n+1}}{n}\left[\frac{\sin 2 n x}{2 n}\right]_{0}^{\frac{\pi}{4}} \\&=-\frac{\pi}{4} \ln 2+\sum_{n=0}^{\infty} \frac{(-1)^{n+1}}{2 n^{2}}\left(\sin \frac{n \pi}{2}\right) \\&=-\frac{\pi}{4} \ln 2+\frac{1}{2} \sum_{n=0}^{\infty} \frac{(-1)^{n}}{(2 n+1)^{2}} \\&=-\frac{\pi}{4} \ln 2+\frac{G}{2},\end{aligned} \tag*{} $$\textrm{where G is the Catalan's constant.}$$

Since $$\cos x =\sqrt{\frac{1+\cos 2x}{2}}$$ so the integral is equal to $$\frac{1}{2}\int_0^{\frac{\pi}{4}}\log\left(\frac{1+\cos 2x}{2}\right)dx =-\frac{\pi}{8}\log(2)+\frac{1}{2}\int_0^{\frac{\pi}{4}}\log\left(1+\cos 2x \right) dx$$ substituting $$2x=y$$ gives us $$\frac{1}{4}\int_0^{\frac{\pi}{2}} \log(1+\cos y) dy$$ which the integral evaluated here and gives us $$-\frac{\pi}{8}\log(2)+\frac{1}{4}\left(2G-\frac{\pi}{2}\log(2)\right)=2G-\frac{\pi}{4}\log(2)$$

The result is straightforward if we use the generalized clausen function (see here) $$\int_0^{\theta} \log(\cos y)dy =\frac{1}{2}\operatorname{Cl}_2\left(\pi -2\theta\right)-\theta \log(2)$$ or $$\int_0^{\theta} \log(1+\cos y)dy=2\operatorname{Cl}_2\left(\pi -\theta \right)-\theta \log(2)$$

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? Commented Sep 19, 2012 at 12:22
• Hmhm, I saw that answer with Catalan constant,can there be a more elementary solution without infinite series? Commented Sep 19, 2012 at 12:26
• Use $\cos(x)=\frac{\exp(i\theta)+\exp(-i\theta)}{2}$ and then integrate it. Commented Sep 19, 2012 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. Commented Sep 19, 2012 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
Commented Sep 19, 2012 at 13:16