Q:

Integrate: $\int_0^{\pi} \log ( 1 - 2 r \cos \theta + r^2)d\theta$

If $r \in \Bbb R$ how to integrate $\displaystyle \int_0^{\pi} \log ( 1  - 2 r \cos \theta + r^2)d\theta$? 
I need some hints. Special case, if $r = 1$ then I know the above integral is zero.
Here is my working
\begin{align*}
\int_0^{\pi}\log (1 - 2 r \cos \theta + r^2)d\theta &= \int_0^\pi\log ((1 - re^{i \theta})(1 -re^{-i\theta} )) d\theta\\ 
 &= \int_0^\pi \log(1 - r e^{i\theta})d\theta + \int_0^\pi\log(1 - re^{-i\theta})d\theta\\ 
 &= \int_0^{2\pi} \log( 1 - re^{i\theta})d\theta \\
 &= 0
\end{align*}

A:

Two hints: 

The integrand is an even function of $\theta$ $\Rightarrow$ the integral can be written as $\frac12\int_0^{2\pi}$.
$1-2r\cos\theta+r^2=(1-re^{i\theta})(1-re^{-i\theta})$.

