# How to evaluate $\int_0^{\pi/2} x^2 \ln^2(2\cos{x}) \mathrm{d}x$

In this post, It is mentioned that $$\int_0^{\pi/2} x^2 \ln^2(2\cos{x}) \mathrm{d}x = \frac{11 \pi}{16} \zeta(4)$$ is easy to evaluate.

I thought it by doing integration by parts but if I assume $$x^2$$ as $$1st$$ function and $$\ln^2(2\cos{x})$$ as $$2nd$$ function but problem with this is that, We can't integrate $$\ln^2(2\cos{x})$$ directly.

I also tried to use Fourier series of $$\ln(2\cos{x})$$ $$\ln(2 \cos(x)) = \sum_{n=1}^\infty \frac{(-1)^{n-1}}{n} \cos(2 n x)$$ But it didn't work as well.

Please guide me how to solve it ? Thank you very much!!

• Hint: differentiate both sides of $$\int_0^{\pi/2} \cos^a x \cos bx dx = \frac{\pi \Gamma(a+1)}{2^{a+1} \Gamma(1+\frac{a-b}{2}) \Gamma(1+\frac{a+b}{2})}$$ and putting $a=b=0$. This enables us to express $$\int_0^{\pi/2} x^{2n} \log^m(2\cos x) dx$$ in terms of Riemann zeta. Dec 18, 2022 at 20:31
• how you got this formula or solved that integral? I mean I know RHS is quite similar to one integral representation of Beta function. But it is not totally like that. Dec 18, 2022 at 20:35
• This is a nice exercise on contour integration, of course it can also be proved by other means. Dec 18, 2022 at 20:53
• the method is, for example, here: math.stackexchange.com/questions/3419834/… Dec 18, 2022 at 20:58
• Thank you @Svyatoslav Dec 19, 2022 at 3:55

We will prove

$$\int_{0}^{\frac{\pi}{2}}x^{2}\ln^{2}\left(2\cos\left(x\right)\right)dx = \frac{11\pi^{5}}{1440}.$$

Proof. Let the given integral be $$I$$. Then \eqalign{ I&=\int_{0}^{\frac{\pi}{2}}x^{2}\ln^{2}\left(2\cos\left(x\right)\right)dx \cr &= \int_{0}^{\frac{\pi}{2}}x^{2}\ln^{2}\left(\frac{e^{2ix}+1}{e^{ix}}\right)dx \cr &= \int_{0}^{\frac{\pi}{2}}x^{2}\left(\ln\left(e^{2ix}+1\right)-ix\right)^{2}dx \cr &= \int_{0}^{\frac{\pi}{2}}x^{2}\ln^{2}\left(1+e^{2ix}\right)dx-2i\int_{0}^{\frac{\pi}{2}}x^{3}\ln\left(1+e^{2ix}\right)dx-\int_{0}^{\frac{\pi}{2}}x^{4}dx \cr &= \int_{0}^{\frac{\pi}{2}}x^{2}\ln^{2}\left(1+e^{2ix}\right)dx-2i\int_{0}^{\frac{\pi}{2}}x^{3}\ln\left(1+e^{2ix}\right)dx-\frac{\pi^{5}}{160} \cr }

For the first integral, let $$f(z) = z^2\log^2\left(1+e^{2iz}\right)$$ and define a rectangular contour

$$C=\left\{z\in\mathbb{C} : \Re(z) \in \left[0,\frac{\pi}{2}\right] \wedge \Im(z) \in \left[0,R\right]\right\}$$

that we will traverse counterclockwise around. By Cauchy's Residue Theorem, we get

$$0 = \int_{0}^{\frac{\pi}{2}}f\left(z\right)dz+\int_{\frac{\pi}{2}}^{\frac{\pi}{2}+iR}f\left(z\right)dz+\int_{\frac{\pi}{2}+iR}^{iR}f\left(z\right)dz+\int_{iR}^{0}f\left(z\right)dz.$$

With some grunt work, the third integral will vanish as $$R\to\infty$$. The fourth integral will also vanish when we take $$\Re$$ on both sides. As $$R \to \infty$$, we get

\eqalign{ \Re\int_{0}^{\frac{\pi}{2}}f\left(z\right)dz &= -\Re\int_{\frac{\pi}{2}}^{\frac{\pi}{2}+i\infty}f\left(z\right)dz \cr &= -\Re i\int_{0}^{R}f\left(\frac{\pi}{2}+ix\right)dx \cr &= -\Re i\int_{0}^{\infty}\left(\frac{\pi}{2}+ix\right)^{2}\log^{2}\left(1+e^{2i\left(\frac{\pi}{2}+ix\right)}\right)dx \cr &= \pi\int_{0}^{\infty}x\ln^{2}\left(1-e^{-2x}\right)dx \cr &= \pi\int_{0}^{\infty}x\left(-\sum_{n=1}^{\infty}\frac{e^{-2nx}}{n}\right)^{2}dx \cr &= \pi\int_{0}^{\infty}x\sum_{n=1}^{\infty}\frac{e^{-2nx}}{n}\sum_{k=1}^{\infty}\frac{e^{-2kx}}{k}dx \cr &= \sum_{n,k=1}^{\infty}\frac{\pi}{nk}\int_{0}^{\infty}xe^{-2\left(n+k\right)x}dx \cr &= \sum_{n,k=1}^{\infty}\frac{\pi}{nk}\left(\frac{1}{4\left(n+k\right)^{2}}\right) \cr &= \frac{\pi}{8}\sum_{n,k=1}^{\infty}\frac{\left(n+k\right)^{2}-n^{2}-k^{2}}{n^{2}k^{2}\left(n+k\right)^{2}} \cr &= \frac{\pi}{8}\sum_{n,k=1}^{\infty}\frac{1}{n^{2}k^{2}}-\frac{\pi}{8}\sum_{n,k=1}^{\infty}\frac{1}{k^{2}\left(n+k\right)^{2}}-\frac{\pi}{8}\sum_{n,k=1}^{\infty}\frac{1}{n^{2}\left(n+k\right)^{2}} \cr &= \frac{\pi}{8}\sum_{n,k=1}^{\infty}\frac{1}{n^{2}k^{2}}-\frac{\pi}{8}\sum_{k=1}^{\infty}\sum_{n=k+1}^{\infty}\frac{1}{k^{2}n^{2}}-\frac{\pi}{8}\sum_{n=1}^{\infty}\sum_{k=n+1}^{\infty}\frac{1}{n^{2}k^{2}} \cr &= \frac{\pi}{8}\sum_{n,k=1}^{\infty}\frac{1}{n^{2}k^{2}}-\frac{\pi}{8}\sum_{1\le k

\eqalign{ \int_{0}^{\frac{\pi}{2}}x^{3}\ln\left(1+e^{2ix}\right)dx &= \int_{0}^{\frac{\pi}{2}}x^{3}\sum_{n=1}^{\infty}\frac{\left(-1\right)^{n+1}e^{2nix}}{n}dx \cr &= \sum_{n=1}^{\infty}\frac{\left(-1\right)^{n+1}}{n}\int_{0}^{\frac{\pi}{2}}x^{3}e^{2nix}dx \cr &= \sum_{n=1}^{\infty}\frac{\left(-1\right)^{n+1}}{n}\left(\frac{6+e^{i\pi n}\left(-6+\pi n\left(\pi n\left(3-i\pi n\right)+6i\right)\right)}{16n^{4}}\right) \cr &= \frac{3}{8}\sum_{n=1}^{\infty}\frac{\left(-1\right)^{n+1}}{n^{5}}+\frac{3}{8}\sum_{n=1}^{\infty}\frac{1}{n^{5}}-\frac{3\pi i}{8}\sum_{n=1}^{\infty}\frac{1}{n^{4}}-\frac{3\pi^{2}}{8}\sum_{n=1}^{\infty}\frac{1}{n^{3}}+\frac{i\pi^{3}}{16}\sum_{n=1}^{\infty}\frac{1}{n^{2}} \cr &= \frac{3}{8}\left(\frac{15}{16}\zeta{(5)}\right)+\frac{3}{8}\zeta{(5)}-\frac{3\pi i}{8}\left(\frac{\pi^{4}}{90}\right)-\frac{3\pi^{2}}{16}\zeta{(3)}+\frac{i\pi^{3}}{16}\left(\frac{\pi^{2}}{6}\right) \cr &= \frac{i\pi^{5}}{160}+\frac{93\zeta{(5)}}{128}-\frac{3\pi^{2}\zeta{(3)}}{16}. \cr }

Gathering everything together and taking the real part of $$I$$, we get

$$\Re I = \frac{\pi^{5}}{720}-\Re 2i\left(\frac{i\pi^{5}}{160}+\frac{93\zeta{(5)}}{128}-\frac{3\pi^{2}\zeta{(3)}}{16}\right)-\frac{\pi^{5}}{160} = \frac{11\pi^{5}}{1440}.$$

In conclusion,

$$\int_{0}^{\frac{\pi}{2}}x^{2}\ln^{2}\left(2\cos\left(x\right)\right)dx = \frac{11\pi^{5}}{1440}.$$

Q.E.D.

• Amazing solution, but sad thing is that I don't know how to do integrals using counters so would you tell me what are some prerequisites to learn counter integrals? Because I tried to learn but they were using too much Real Analysis in that so.... Thank you very much ! Dec 19, 2022 at 3:58
• Thanks for the comment! I don't think there are specific prerequisites for learning contour integrals since contour integration varies a lot in techniques. To be successful at it requires a lot of practice and knowledge. I would recommend just getting your hands dirty on the basics of complex numbers and real analysis. You could try reading this. Once you feel comfortable with that stuff, then you can explore this YouTube channel and this website. @Luckychouhan Dec 19, 2022 at 4:09
• Wow! Thank you! You helped me a lot, I didn't even know about those amazing website that you mentioned. Have a mathematical day! Dec 19, 2022 at 4:12
• You too! Thank you for the interesting integral. @Luckychouhan Dec 19, 2022 at 4:13
• Beautiful solution. That was a good read! (+1) Dec 19, 2022 at 15:23

Using the Fourier expansion does work, though I have yet to completely evaluate every sum that makes up the overall integral. Recall the log-sine expansion,

$$\ln(\sin(x))=-\ln(2)-\sum_{k=1}^\infty \frac{\cos(2kx)}k$$

Expand the integrand as

$$x^2 \ln^2(2\cos(x)) = x^2 \bigg(\ln^2(2) + 2 \ln(2) \ln(\cos(x)) + \ln^2(\cos(x))\bigg)$$

Let

$$I_{m,n} = \int_0^{\frac\pi2} x^m \ln^n(\sin(x)) \, dx$$

so that

\begin{align*} \mathcal I &= \int_0^{\frac\pi2} x^2 \ln^2(2\cos(x)) \, dx \\[1ex] &= \ln^2(2) I_{2,0} + 2\ln(2) I_{2,1} + I_{2,2} \end{align*}

\begin{align*} I_{2,0} &= \int_0^{\frac\pi2} x^2 \, dx \\[1ex] &= \frac{\pi^3}{24} \end{align*}

\begin{align*} I_{2,1} &= - \int_0^{\frac\pi2} \left(\frac\pi2-x\right)^2 \left(\ln(2) + \sum_{k=1}^\infty \frac{\cos(2kx)}k\right) \, dx \\[1ex] &= -\frac{\pi^3}{24}\ln(2) - \sum_{k=1}^\infty \frac1k \int_0^{\frac\pi2} \left(\frac\pi2-x\right)^2 \cos(2kx) \, dx \\[1ex] &= -\frac{\pi^3}{24}\ln(2) - \sum_{k=1}^\infty \frac1{2k} \int_0^\pi \left(\frac\pi2-\frac x2\right)^2 \cos(kx) \, dx \\[1ex] &= -\frac{\pi^3}{24}\ln(2) - \sum_{k=1}^\infty \frac\pi{4k} \left(\frac{(-1)^k}{k^2} - \frac{-1+(-1)^k}{k^2}\right) \\[1ex] &= -\frac{\pi^3}{24}\ln(2) - \frac\pi4 \zeta(3) \end{align*}

\begin{align*} I_{2,2} &= \int_0^{\frac\pi2} \left(\frac\pi2-x\right)^2 \left(-\ln(2)-\sum_{k=1}^\infty \frac{\cos(2kx)}k\right)^2 \, dx \\[1ex] &= \int_0^{\frac\pi2} \left(\frac\pi2-x\right)^2 \left(\ln^2(2) + 2 \ln(2) \sum_{k=1}^\infty \frac{\cos(2kx)}k + \left(\sum_{k=1}^\infty \frac{\cos(2kx)}k\right)^2\right) \, dx \\[1ex] &= \frac{\pi^3}{24}\ln^2(2) + \frac\pi4 \zeta(3) + \int_0^{\frac\pi2} \left(\frac\pi2-x\right)^2 \left(\sum_{k=1}^\infty \frac{\cos(2kx)}k\right)^2 \, dx \\[1ex] &= \frac{\pi^3}{24}\ln^2(2) + \frac\pi4 \zeta(3) \\ &\qquad + \int_0^{\frac\pi2} \left(\frac\pi2-x\right)^2 \left(\sum_{k=1}^\infty \frac{\cos^2(2kx)}{k^2} + 2 \sum_{(k_1,k_2)\in\Bbb N^2} \frac{\cos(2k_1x)\cos(2k_2)x}{k_1k_2}\right) \, dx \\[1ex] &= \frac{\pi^3}{24}\ln^2(2) + \frac\pi4 \zeta(3) + \sum_{k=1}^\infty \frac1{4k^2} \left(\frac{\pi^3}{12} + \frac\pi{8k^2}\right) \\ &\qquad + \frac\pi4 \sum_{(k_1,k_2)\in\Bbb N^2} \frac1{k_1k_2} \left(\frac1{(k_1+k_2)^2} + \frac1{(k_1-k_2)^2}\right) \\[1ex] &= \frac{\pi^3}{24}\ln^2(2) + \frac\pi4 \zeta(3) + \frac{11\pi^5}{2880} \\&\qquad + \frac\pi4 \sum_{(k_1,k_2)\in\Bbb N^2} \frac1{k_1k_2} \left(\frac1{(k_1+k_2)^2} + \frac1{(k_1-k_2)^2}\right) \\[1ex] &= \frac{\pi^3}{24}\ln^2(2) + \frac\pi8 \zeta(3) + \frac{3\pi^5}{320} \\&\qquad + \frac\pi4 \sum_{(k_1,k_2)\in\Bbb N^2} \frac1{k_1k_2} \frac1{(k_1-k_2)^2} \end{align*}

where in the double sum, $$k_1\neq k_2$$.

To evaluate the first sum in $$I_{2,2}$$, I've used the same approach as shown here. Let

$$g(x) = \sum_{a=1}^\infty \sum_{b=1}^\infty \frac{x^{a+b}}{ab(a+b)^2}$$

Note that this includes the case of $$a=b$$. Differentiate and multiply by $$x$$ to recover $$f$$ (as in linked answer), integrate by parts to solve for $$g$$, and let $$x\to1$$ from below.

\begin{align*} g'(x) &= \frac1x \int_0^x \frac{\ln^2(1-y)}y\,dy\\ &= \frac{\ln(x)\ln^2(1-x)+2\ln(1-x)\operatorname{Li}_2(1-x)-2\operatorname{Li}_3(1-x)}x \end{align*}

Integrate by parts again to get

\begin{align*} \sum_{(a,b)\in\Bbb N^2} \frac1{ab(a+b)^2} &= \int_0^1 \frac{\ln(x)\ln^2(1-x)+2\ln(1-x)\operatorname{Li}_2(1-x)-2\operatorname{Li}_3(1-x)}x\,dx \\ &= -\int_0^1 \frac{\ln(x)\ln^2(1-x)}x \, dx \end{align*}

where IBP shows the last two integrals are absorbed into the first. Recalling the generating function for $$H_n$$ the harmonic numbers, $$-\frac{\ln(1-x)}{1-x}$$, it follows that

$$\sum_{(k_1,k_2)\in\Bbb N^2} \frac1{k_1k_3(k_1+k_2)^2} = \sum_{n=1}^\infty \frac{2H_n}{(n+1)^3} - \sum_{n=1}^\infty \frac1{2n^3} = \frac{\pi^4}{180} - \frac{\zeta(3)}2$$

#### in-progress

The second sum of $$I_{2,2}$$ still remains,

$$\sum_{(k_1,k_2)\in\Bbb N^2} \frac1{k_1k_2} \frac1{(k_1-k_2)^2}$$

• Amazing solution, Thank you very much ! But I have one question is that "How you solved $\left( \sum_{n=1}^\infty \frac{\cos{2kx}}{k} \right)^2$ ?' I mean in $I_{2,2}$ in 4th step where you simplified it. You used Cauchy product? Because while using Fourier series this was the thing that was terrifying me.. Dec 19, 2022 at 7:40
• Multinomial expansion. It's a generalization of the pattern$$(x+y)^2=x^2+y^2+2xy\\(x+y+z)^2=x^2+y^2+z^2+2(xy+xz+yz)$$and so on. Dec 19, 2022 at 8:20
• @Luckychouhan I've added some more to my answer. Still not quite finished, however. If nothing else, I hope I've demonstrated Accelerator's answer to be far less cumbersome :) Dec 20, 2022 at 3:33
• Yeah Now it is clear, Thank you very much. And sorry from my side because I'm replying to you late even though thing was of my favor, because of college stuff I didn't visit MSE site. But thank you again because of you I learned Multinomial expression and solving double summation. Have a mathematical day! Dec 20, 2022 at 12:51

Using $$\ln^2(2\cos x)=x^2+2\sum_{n=1}^\infty(-1)^n\frac{H_{n-1}}{n}\cos(2nx),\quad |x|<\frac{\pi}{2}$$ we have

$$\int_0^{\pi/2} x^2 \ln^2(2\cos{x}) \mathrm{d}x=\int_0^{\pi/2} x^4 \mathrm{d}x+2\sum_{n=1}^\infty(-1)^n\frac{H_{n-1}}{n}\int_0^{\pi/2} x^2\cos(2nx) \mathrm{d}x$$

$$=\frac{\pi^5}{160}+2\sum_{n=1}^\infty(-1)^n\frac{H_{n-1}}{n}\left(\frac{\pi\cos(n\pi)}{4n^2}-\frac{\sin(n\pi)}{4n^3}+\frac{\pi^2\sin(n\pi)}{8n}\right)$$

$$=\frac{\pi^5}{160}+2\sum_{n=1}^\infty(-1)^n\frac{H_{n-1}}{n}\left(\frac{\pi(-1)^n}{4n^2}\right)$$ $$=\frac{\pi^5}{160}+\frac{\pi}{2}\sum_{n=1}^\infty\frac{H_{n}}{n^3}-\frac{\pi}{2}\zeta(4)=\frac{11\pi^{5}}{1440}.$$

• Sir, I'm blessed today, I got answer from you. I have studied your book on Integrals & Harmonic series more than half. Thank you very much sir for your amazing solution. Sorry for being late, was traveling today. Jan 15, 2023 at 17:12
• You welcome and thank you for the kind words. Jan 15, 2023 at 18:03