# Evaluate $\int_0^{\pi/2}\log\cos(x)\,\mathrm{d}x$

How can you evaluate $$\int\limits_0^{\pi/2}\log\cos(x)\,\mathrm{d}x\;?$$

• What is the context for this question? The anti-derivative is not elementary (I ran it on WA and thought "Oh cool, dilogarithms!"). – colormegone Feb 26 '14 at 3:05
• @RecklessReckoner The anti-derivative needn't be found for this particular problem. The answer ought to be $-\pi \log(2)/2$, but I suspect it has been asked here (or elsewhere) before... – Benjamin Dickman Feb 26 '14 at 3:27
• After seeing the result, I figured this was one that had to be evaluated over a specific interval, like many "complete" integral functions. This is a new one to me. Thanks, I'll add this to the collection. – colormegone Feb 26 '14 at 6:41
• The following recent question in progress is related: A closed form for $\int_0^{π/2} x^3\ln^3(2\cos x)dx$. (As a small plug, the method in my answer there includes this one as a special case.) – Semiclassical Jul 15 '14 at 13:54

For the sake of simplicity, all the integral variables I use are $x$ even there are a lot of substitutions. Because lots of variables could make one confused.

Let $I$ denote the integral value. By substitute $x$ for $\pi/2-x$, we have: \begin{equation} I=\int_0^{\frac{\pi}{2}}\log\cos(x)dx=\int_0^{\frac{\pi}{2}}\log\sin(x)dx \end{equation} And then, we have: \begin{equation} I=\int_0^{\frac{\pi}{2}}\log(2\cos(\frac{x}{2})\sin(\frac{x}{2}))dx\\ =\frac{\pi}{2}\log2+\int_0^{\frac{\pi}{2}}\log\cos(\frac{x}{2})dx+\int_0^{\frac{\pi}{2}}\log\sin(\frac{x}{2})dx\\ =\frac{\pi}{2}\log2+2\int_0^{\frac{\pi}{4}}\log\cos(x)dx+2\int_0^{\frac{\pi}{4}}\log\sin(x)dx\\ =\frac{\pi}{2}\log2+I_1+I_2 \end{equation} In the second step from bottom, I use the substitution that $x=x/2$.

For $I_1$, use the substitution that $x=\pi/2-x$ we obtain \begin{equation} I_1=2\int_{\frac{\pi}{4}}^{\frac{\pi}{2}}\log\sin(x)dx \end{equation} It gives that $I_1+I_2=2I$. So we have \begin{equation} I=\frac{\pi}{2}\log2+2I\\ I=-\frac{\pi}{2}\log2 \end{equation}

• I have learnt something I probably should of thought of (seen) before. So thank you :). +1 – Chinny84 Jul 15 '14 at 13:42

$$\int_0^{\pi/2} \ln \cos xdx =I=\int_0^{\pi/2} \ln \sin x dx.$$ By symmetry we have $\ln \cos x=\ln \sin x$ on the interval $[0,\pi/2]$. This is true for any even/odd function on this interval, as is an exercise in Demidovich-Problems in Analysis. Thus we have $$2I=\int_0^{\pi/2}\ln \cos x dx+ \int_0^{\pi/2} \ln \sin x dx= \int_0^{\pi/2} \ln(\sin x \cos x)dx=\int_0^{\pi/2} \ln\big(\frac{1}{2}\cdot\sin(2x)\big) dx.$$ All I used was $\ln(a\cdot b)=\ln(a)+\ln(b)$ and $2\sin x \cos x=\sin(2x)$. Now we split the integral back up to obtain $$-\int_0^{\pi/2}\ln(2)dx+\int_0^{\pi/2}\ln(\sin(2x))dx=2I.$$ Thus we can now substitute $u=2x$ to obtain $$-\frac{\pi\ln(2)}{2}+\frac{1}{2}\int_0^\pi \ln \sin (u) du=2I$$ But the integral of $\ln \sin u$ is 2I, thus we have $$-\frac{\pi\ln(2)}{2}+I=2I, \ \to {\boxed{I=-\frac{\pi \ln(2)}{2}.}}$$

• +2 from me Jeff. Nice answers. :) – Tunk-Fey Apr 22 '14 at 18:58
• @Tunk-Fey Thank you my friend! – Jeff Faraci Apr 22 '14 at 19:51
• @Integrals Hello. I am having difficulty seeing why $\int_0^\pi \ln \sin(u) du$ is $2I$. Would you mind showing me why? – user193319 Mar 12 '17 at 16:33
• @user193319 Good question, $$\int_0^{\pi} \ln \sin (u) du =\int_0^{\pi/2}\ln \sin (u) du + \int_{\pi/2}^{\pi}\ln \sin (u) du$$ Now the first integral is obviously just our integral $I$, for the second integral let $u=x+\pi/2$ to obtain $$I+\int_0^{\pi/2}\ln (\sin (x+\pi/2))dx= I+\int_0^{\pi/2}\ln \cos (x) dx$$ but we know this second integral is indeed $I$ also, so we have just $$I+\int_0^{\pi/2}\ln \cos (x) dx=I+\int_0^{\pi/2}\ln \sin( x) dx=I+I=2I.$$ Alternatively, you can plot the integrand and visually see the area for $x \in [0,\pi]$ but thats not a proof obviously. – Jeff Faraci Mar 12 '17 at 19:00

How comes I forgot to write my favorite proof?

We have a well-known identity:

$$\prod_{k=1}^{n-1}\sin\left(\frac{\pi k}{n}\right)=\frac{2n}{2^n}\tag{1}$$ and since $\log\sin x$ is an improperly Riemann-integrable function over $(0,\pi)$, it follows that:

$$\int_{0}^{\pi}\log\sin\theta\,d\theta = \lim_{n\to +\infty}\frac{\pi}{n}\sum_{k=1}^{n-1}\log\sin\left(\frac{\pi k}{n}\right)=-\pi\log 2,\tag{2}$$ so: $$\int_{0}^{\pi/2}\log\cos\theta\,d\theta = \int_{0}^{\pi/2}\log\sin\theta\,d\theta = \color{red}{-\frac{\pi}{2}\log 2}.\tag{3}$$

• Stop asking "What's the downvote for?" and replace that with "What's the lack of upvotes for?" because you always surprise me with your awesome answers. – Simply Beautiful Art Mar 29 '17 at 21:34

Here is an approach. Making the changes of variables $u=\cos x$ and $u^2=t$ in a row gives

$$I = \frac{1}{4}\int _{0}^{1}\!\,{\frac {\ln \left( t \right) }{\sqrt {1-t} \sqrt {t}}}{dt} .$$

To evaluate the above integral, let's consider the following beta function

$$F = \int_{0}^{1} t^a (1-t)^b dt = \beta(a+1,b+1)=\frac{\Gamma(a+1)\Gamma(b+1)}{\Gamma(a+b+2)} .$$

Now, our integral follows from $F$ as

$$I = \lim_{b\to -1/2}\lim_{a\to -1/2}F_a(a,b)=-\frac{\pi\ln 2}{2},\quad F_a =\frac{dF}{da}.$$

Here is a hint:

1. Let $\displaystyle I = \int_{x=0}^{\pi/2} \log \cos x \, dx$.
2. By choosing a suitable substitution, show we also have $\displaystyle I = \int_{x=0}^{\pi/2} \log \sin x \, dx$.
3. Using a symmetry argument, also show that $\displaystyle I = \int_{x=\pi/2}^\pi \log \sin x \, dx$.
4. Add the results of (1) and (2) together to get an expression for $2I$.
5. Transform the integrand using properties of logarithms and a double-angle identity.
6. Use (3) to rewrite the result of (5) in terms of $I$ in a second way.
7. Solve for $I$.

Here is another solution: As we have $\cos(x)=\frac{e^{ix}+e^{-ix}}{2}=\frac{e^{2ix}+1}{2e^{ix}}$ we get: $$I=\int_0^{\frac{\pi}{2}} \ln(\cos(x))dx=\int_0^{\frac{\pi}{2}} \ln(e^{2ix}+1)dx-\int_0^{\frac{\pi}{2}} \ln(2)dx-\int_0^{\frac{\pi}{2}} ixdx$$ By using the series expansion of $\ln(x)$ and by calculating the two simple integrals we obtain: $$I=\int_0^{\frac{\pi}{2}} \sum_{k=0}^\infty \frac{(-1)^k}{k+1}\cdot e^{2ix(k+1)}dx-\frac{\pi}{2}\cdot \ln(2)-i\frac{\pi^2}{8}$$ By swapping the integral and the sum, the integral of the infinite sum can be calculated as follows: $$\int_0^{\frac{\pi}{2}} \sum_{k=0}^\infty \frac{(-1)^k}{k+1}\cdot e^{2ix(k+1)}dx=\sum_{k=0}^\infty \frac{(-1)^k}{k+1}\cdot \int_0^{\frac{\pi}{2}}e^{2ix(k+1)}dx=\sum_{k=0}^\infty \frac{(-1)^k}{k+1}\cdot \left(\frac{e^{i\pi(k+1)}-1}{2i(k+1)}\right)=\frac{i}{2}\cdot\sum_{k=0}^\infty \frac{(-1)^k}{k+1}\cdot \left(\frac{1-(-1)^{k+1}}{(k+1)}\right)$$ Here I used, that $\frac{1}{i}=-i$. Now, when $k$ is uneven, the expression after the sigma is equal to $0$, this yields: $$\frac{i}{2}\cdot\sum_{k=0}^\infty \frac{(-1)^k}{k+1}\cdot \left(\frac{1-(-1)^{k+1}}{(k+1)}\right)=\frac{i}{2}\cdot\sum_{k=0}^\infty \frac{2\cdot(-1)^{2k}}{(2k+1)^2}=i\cdot\sum_{k=0}^\infty \frac{1}{(2k+1)^2}=i\cdot\left(\sum_{k=1}^\infty \frac{1}{k^2}-\sum_{k=1}^\infty \frac{1}{(2k)^2}\right)=i\cdot\frac{3}{4}\cdot\zeta(2)=i\frac{\pi^2}{8}$$ Therefore, $I$ can be expressed as follows: $$I=i\frac{\pi^2}{8}-\frac{\pi}{2}\cdot \ln(2)-i\frac{\pi^2}{8}=-\frac{\pi}{2}\cdot \ln(2)$$

• it's a brilliant method , but how can you manipulate a complex value i.e $i$ inside a real integral ? can we do that ? – JohnnySinns Jun 7 '17 at 17:18