<s>[INST] Evaluating $\int_{0}^{\frac{\pi}{2}} x^{2} \ln (\cos x) d x$ Latest Edit
As suggested by Mr Claude Leibovici, I go further to investigate the integral in general,
$$I_{m}:=\int_{0}^{\frac{\pi}{2}} x^{m} \ln (\cos x) d x$$
By the Fourier Series of ln(cos x)
,
$ \displaystyle \ln (\cos x)=-\ln 2+\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} \cos (2 n x) \tag*{(*)} $
Multiplying (*) by $ x^m$ and then Integrating both sides from $0 $ to $\frac{\pi}{2}$ yields
$$\begin{aligned}
I_m&=-\int_{0}^{\frac{\pi}{2}} x^{m} \ln 2 d x+\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n !} \int_{0}^{\frac{\pi}{2}} x^{m} \cos (2 n x) d x\\&= -\frac{\pi^{m+1}\ln 2}{(m+1) 2^{m+1}}+\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} J(m, n)\end{aligned}
$$
Next we need a reduction formula on $J(m,n)$.
Applying integration by parts twice, we obtain
$$
\begin{aligned}J(m, n)&=\frac{1}{2 n} \int_{0}^{\frac{\pi}{2}} x^{m} d(\sin 2 n x)\\ &= -\frac{m}{2 n} \int_{0}^{\frac{\pi}{2}} x^{m-1} \sin 2 n x d x\\&=\frac{m}{4 n^{2}} \int_{0}^{\frac{\pi}{2}} x^{m-1} d(\cos 2 n x)\\&=\frac{(-1)^{n} \pi^{m-1} m}{2^{m+1} n^{2}} -\frac{m(m-1)}{4 n^{2}} J (m-2, n)\end{aligned}
$$
By the reduction formula of $J(m,n)$, we can find $I_m$ by plugging $J(m,n)$.

By the Fourier Series of ln(cos x)
,
$ \displaystyle \ln (\cos x)=-\ln 2+\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} \cos (2 n x) \tag*{(*)} $
Multiplying (*) by $ x^2$ and then Integrating both sides from $0 $ to $\frac{\pi}{2}$ yields
$\displaystyle I=-\underbrace{\int_{0}^{\frac{\pi}{2}} x^{2} \ln 2 d x}_{\frac{\pi^{3} \ln 2}{24}}+\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} \underbrace{ \int_{0}^{\frac{\pi}{2}} x^{2} \cos (2 n x) d x}_{J_n}\tag*{} $
Integrating by parts twice yields
$\displaystyle \begin{aligned}J_{n} &=\frac{1}{2 n} \int_{0}^{\frac{\pi}{2}} x^{2} d(\sin 2 n x) \\&=\frac{1}{2 n}\left[x^{2} \sin 2 n x\right]_{0}^{\frac{\pi}{2}}-\frac{1}{n} \int_{0}^{\frac{\pi}{2}} x \sin 2 n x d x \\&=\frac{1}{2 n^{2}} \int_{0}^{\frac{\pi}{2}} x d(\cos 2 n x) \\&=\left[\frac{1}{2 n^{2}} x \cos 2 n x\right]_{0}^{\frac{\pi}{2}}-\frac{1}{2 n^{2}} \int_{0}^{\frac{\pi}{2}} \cos 2 n x d x \\&=\frac{\pi}{4 n^{2}} \cos n \pi-\frac{1}{2 n^{2}}\left[\frac{\sin 2 n x}{2 n}\right]_{0}^{\frac{\pi}{2}} \\&=\frac{\pi}{4 n^{2}} \cos n \pi\end{aligned}\tag*{} $
We can now conclude that
$\displaystyle \begin{aligned}I &=-\frac{\pi^{3} \ln 2}{24}+\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} \cdot \frac{\pi}{4 n^{2}} \cos n \pi \\&=-\frac{\pi^{3} \ln 2}{24}+\frac{\pi}{4} \sum_{n=1}^{\infty} \frac{(-1)^{n+1}(-1)^{n}}{n^{3}} \\&=-\frac{\pi^{3} \ln 2}{24}-\frac{\pi}{4} \sum_{n=1}^{\infty} \frac{1}{n^{3}} \\&=\boxed{-\frac{\pi^{3} \ln 2}{24}-\frac{\pi}{4} \zeta(3)}\end{aligned}\tag*{} $
Is there any other method to evaluate $I$?
 [/INST] Using $(*)$, I think that we could even make the problem more general using the incomplete gamma function or the exponential integral function
$$\int x^p \cos(2nx)\,dx=-\frac{1}{2} x^{p+1} (E_{-p}(-2 i n x)+E_{-p}(2 i n x))$$
$$K_p=\int_0^{\frac \pi 2} x^p \cos(2nx)\,dx=$$ $$-i^{p+1} 2^{-p-2} n^{-p-1} \left(\Gamma (p+1,-i n \pi )-(-1)^p \Gamma (p+1,i n \pi
   )+\left((-1)^p-1\right) \Gamma (p+1)\right)$$ which simplifies a lot if $p$ is even
$$K_{2m}=i\,(-1)^{m+1} \,2^{-2 (m+1)}\,n^{-(2m+1)}\,(\Gamma (2 m+1,-i n \pi )-\Gamma (2 m+1,i n \pi ))$$
So, as you found
$$K_2=\frac{\left(\pi ^2 n^2-2\right) \sin (\pi  n)+2 \pi  n \cos (\pi  n)}{8 n^3}=(-1)^n\frac{\pi  }{4 n^2}$$
$$K_4=(-1)^n \frac{\pi   \left(\pi ^2 n^2-6\right)}{8 n^4}\qquad \qquad K_6=(-1)^n \frac{3 \pi  \left(\pi ^4 n^4-20 \pi ^2 n^2+120\right)}{64 n^6}$$
$$\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} K_2=-\frac{\pi  }{4}\zeta (3)$$
$$\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} K_4=-\frac{\pi}{8}   \left(\pi ^2 \zeta (3)-6 \zeta (5)\right)$$
$$\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} K_6=-\frac{3\pi}{64}   \left(\pi ^4 \zeta (3)-20 \pi ^2 \zeta (5)+120 \zeta (7)\right)$$
$$\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} K_8=-\frac{\pi }{64}  \left(\pi ^6 \zeta (3)-42 \pi ^4 \zeta (5)+840 \pi ^2 \zeta (7)-5040
   \zeta (9)\right)$$
Edit
In fact, no much problem if $p$ is odd
$$\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} K_1=-\frac{7 }{16}\zeta (3)$$
$$\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} K_3=-\frac{3}{128} \left(8 \pi ^2 \zeta (3)-31 \zeta (5)\right)$$
$$\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} K_5=-\frac{5}{512} \left(8 \pi ^4 \zeta (3)-96 \pi ^2 \zeta (5)+381 \zeta (7)\right)$$
$$\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} K_7=-\frac{7}{4096} \left(16 \pi ^6 \zeta (3)-480 \pi ^4 \zeta (5)+5760 \pi ^2 \zeta (7)-22995 \zeta
   (9)\right)$$
</s>