How to prove
$$I=\int_0^{\pi/2} x^2\left(\sum_{n=1}^\infty (-1)^{n-1} \cos^n(x)\cos(nx)\right)dx=\frac16\left(\frac{\pi^3}{12}-\pi\operatorname{Li}_2\left(\frac13\right)\right)$$
This problem is proposed by Cornel which can be found here where he suggested that the problem can be solved with and without harmonic series.
Here is my approach but I got stuck at the blue integral:
Using the common identity
$$ \sum_{n=1}^{\infty}p^n \cos(nx)=\frac{p(\cos(x)-p)}{1-2p\cos(x)+p^2}, \ |p|<1$$
Set $p=-\cos(x)$ we get
$$ \sum_{n=1}^{\infty}(-1)^n \cos^n(x) \cos(nx)=-\frac{2\cos^2(x)}{1+3\cos^2(x)}=-\frac23+\frac23\frac1{1+3\cos^2(x)}$$
Multiply both sides by $-x^2$ then integrate from $x=0$ to $\pi/2$ we get
$$\int_0^{\pi/2} x^2\left(\sum_{n=1}^\infty (-1)^{n-1} \cos^n(x)\cos(nx)\right)dx=\frac23\int_0^{\pi/2} x^2dx-\frac23\color{blue}{\int_0^{\pi/2}\frac{x^2}{1+3\cos^2(x)}dx}\\=\frac{\pi^3}{36}-\frac23\left(\color{blue}{\frac{\pi^3}{48}+\frac{\pi}{4}\operatorname{Li}_2\left(\frac13\right)}\right)=\frac{\pi^3}{72}-\frac{\pi}{6}\operatorname{Li}_2\left(\frac13\right)$$
I have two Questions:
1) Can we evaluate $I$ in a different way?
2) How to finish the blue integral?
My try to the blue integral is using integration by parts
$$\int\frac{dx}{1+3\cos^2(x)}=\frac12\tan^{-1}\left(\frac{\tan(x)}{2}\right)=-\frac12\tan^{-1}\left(2\cot(x)\right)$$
which gives us
$$\int_0^{\pi/2}\frac{x^2}{1+3\cos^2(x)}dx=\frac{\pi^3}{16}-\int_0^{\pi/2}x\tan^{-1}\left(\frac{\tan(x)}{2}\right)dx$$
Or
$$\int_0^{\pi/2}\frac{x^2}{1+3\cos^2(x)}dx=\int_0^{\pi/2}x\tan^{-1}\left(2\cot(x)\right)dx$$
I also tried the trick $x\to \pi/2-x$ but got complicated
Proof of the identity:
\begin{align} \sum_{n=0}^\infty p^ne^{inx}&=\sum_{n=0}^\infty\left(p e^{ix}\right)^n=\frac{1}{1-pe^{ix}},\quad |p|<1\\&=\frac{1}{1-p\cos(x)-ip\sin(x)}=\frac{1-p\cos(x)+ip\sin(x)}{1-2p\cos(x)+p^2}\\ &=\frac{1-p\cos(x)}{1-2p\cos(x)+p^2}+i\frac{p\sin(x)}{1-2p\cos(x)+p^2} \end{align}
By comparing the real and imaginary parts, we get
$$\sum_{n=\color{blue}{0}}^\infty p^n \cos(nx)=\frac{1-p\cos(x)}{1-2p\cos(x)+p^2}\Longrightarrow \sum_{n=\color{blue}{1}}^\infty p^{n-1} \cos(nx)=\frac{\cos(x)-p}{1-2p\cos(x)+p^2}$$
and
$$\sum_{n=\color{red}{0}}^\infty p^n \sin(nx)=\frac{p\sin(x)}{1-2p\cos(x)+p^2}\Longrightarrow \sum_{n=\color{red}{1}}^\infty p^n \sin(nx)=\frac{p\sin(x)}{1-2p\cos(x)+p^2}$$