TITLE: $\int_{0}^{\pi }{\ln \left( 1-2a\cos x+{{a}^{2}} \right)\cos \left( nx \right)dx}$
QUESTION [5 upvotes]: This integral seems to me not easy to figure it out 
$$\int_{0}^{\pi }{\ln \left( 1-2a\cos x+{{a}^{2}} \right)\cos \left( nx \right)dx}$$
for $n=1,2,3,...$ and $a\in\mathbb{R}$.
I start thinking in using this $f(x)=f(\pi-0+x)$ with integrals for both sides 
but it never help me at all , then I switch to induction to obtain some formula also failed . As a result, is there any shortcut to crack this exercise ?

REPLY [5 votes]: Assume $|a|<1$. Then
$$ \begin {align}
\log(1-2a\cos x+a^2) &= \log((1-ae^{ix})(1-ae^{-ix}))\\
&= \log{(1-ae^{ix})}+\log(1-ae^{-ix}) \\
&= -\sum_{k=1}^{\infty} \frac{1}{k}a^k (e^{ikx}+e^{-ikx})\\
&= -2\sum_{k=1}^{\infty} \frac{a^k}{k} \cos{kx}.\tag1\end {align}$$
Observe that by Dirichlet's test the series $(1)$ converges for $|a|=1$ as well except for the following points:
$$
\begin{cases}
a=1,& x=2n\pi;\\
a=-1,&x=(2n+1)\pi,
\end{cases}\quad n\in\mathbb Z.
$$
This divergence at a set of a measure $0$ however does not matter for the subsequent integration, so that $|a|\le1$ will be assumed. 
Thus:
$$ \int_0^\pi\log(1-2a\cos x+a^2)\cos nx\, dx=-2\sum_{k=1}^{\infty} \frac{a^k}{k}\int_0^\pi \cos{kx}\cos nx\, dx=-\frac {a^n}n\pi.\tag2
$$
For $|a|>1$, we can write:
$$
\log(1-2a\cos x+a^2)=\log(1-2a^{-1}\cos x+a^{-2})+\log a^2,
$$
so that after integration one obtains already known expression $(2) $ with $a $ replaced by $a^{-1}$ since integration over $\log a^2\cos nx$ results in $0$.
Thus, finally
$$\int_0^\pi\log(1-2a\cos x+a^2)\cos nx\, dx=-\frac\pi n\times\begin{cases}
a^n,& |a|\le 1,\\
a^{-n},& |a|>1.\\
\end{cases}
$$