Calculating $\int_0^\pi \log(1-2a\cos (x)+a^2)\,dx$ I need to calculate this integral using Riemann sum.
$$\int_0 ^\pi \log(1-2\alpha \cos (x) +\alpha^2){\rm d}x$$
a). For $|\alpha|<1$; b). For $|\alpha| > 1$.
I know one way of computing this using substitutions and symmetries, but it is necessary to do with Riemann sum. Help please.
UPD:Also, I know that decomposition of a polynomial $a^2n$  into quadratic factors is helpful.
 A: I don't think it's possible to solve such a hard integral with a Riemann sum.
Anyway, by Cauchy's theorem we have $$I=\oint_{|z|=1} \frac{\log(a-z)}{z}dz = 2\pi i\log(a).$$
(assuming $|a| > 1$ so that the branch point is outside the contour). Now let's parametrise the function using $z= e^{it}$ for $0 \leq t \leq 2\pi$:
$$I = \int_0^{2\pi} \frac{\log(a - e^{it})}{e^{it}}i e^{it} dt = i\int_0^{2\pi}\log(a - e^{it})\ dt.$$
Now, $\log(a - e^{it}) = \log(a - \cos t - i \sin t) = \log(\sqrt{(a-\cos t)^2 + \sin^2 t}\ \exp(i \arctan \frac{-\sin t}{a - \cos t}))$ which is equal to $$\frac{1}{2}\log(1+ a^2- 2a\cos t) + i\arctan\frac{-\sin t}{a - \cos t}$$
assuming that we chose a nice branch of the complex logarithm. Now since we know that $I$ is imaginary we can safely discard the imaginary part of the integral to find:
$$2\pi \log a = \frac{1}{2} \int_0^{2\pi} \log(1 - a^2 + 2a\cos t)\ dt = \int_0^\pi \log(1-a^2 +2a\cos t)\ dt.$$
A: Here is an elementary real method.
Let 
$$I(a) = \int^\pi_0 \ln (1 - 2a \cos x + a^2) \, dx, \quad a \in \mathbb{R}.$$
To find the value of $I(a)$ a number of properties for the function $I(a)$ will be estiblished. 
Firstly, note that $I(0) = 0$. Also $I(a)$ is even since
\begin{align*}
I(-a) &= \int^\pi_0 \ln (1 + 2a \cos x + a^2) \, dx\\
x \mapsto \pi - x \atop &= \int^\pi_0 \ln (1 + 2a \cos (\pi - x) + a^2) \, dx\\
&= \int^\pi_0 \ln (1 - 2a \cos x + a^2) \, dx\\
&= I(a).
\end{align*}
Next, observe that provided $a \neq 0$
\begin{align*}
I \left (\frac{1}{a} \right ) &= \int^\pi_0 \ln \left (1 - \frac{2}{a} \cos x + \frac{1}{a^2} \right ) \, dx\\
&= \int^\pi_0 \ln (1 - 2a \cos x + a^2) \, dx - 2 \ln |a| \int^\pi_0 dx,\\
&= I(a) - 2 \pi \ln |a|,
\end{align*}
or
$$I(a) = 2 \pi \ln |a| + I \left (\frac{1}{a} \right ). \tag1$$
Now consider the sum $I(a) + I(-a)$.
\begin{align*}
I(a) + I(-a) &= \int^\pi_0 \ln (1 - 2a \cos x + a^2) \, dx + \int^\pi_0 \ln (1 + 2a \cos x + a^2) \, dx\\
&= \int^\pi_0 \ln [1 + 2a^2 (1 - 2 \cos^2 x) + a^4] \, dx\\
&= \int^\pi_0 \ln (1 + 2a^2 \cos 2x + a^4) \, dx\\
x \mapsto x/2 \atop &= \frac{1}{2} \int^{2\pi}_0 \ln (1 + 2a^2 \cos x + a^4) \, dx\\
&= \frac{1}{2} \int^\pi_0 \ln (1 + 2a^2 \cos x + a^4) \, dx + \frac{1}{2} \int^{2\pi}_\pi \ln (1 + 2a^2 \cos x + a^4) \, dx\\
x \mapsto 2\pi - x \atop &= \frac{1}{2} \int^\pi_0 \ln (1 + 2a^2 \cos x + a^4) \, dx + \frac{1}{2} \int^\pi_0 \ln (1 + 2a^2 \cos (2\pi - x) + a^4) \, dx\\
&= \int^\pi_0 \ln (1 + 2a^2 \cos x + a^4) \, dx\\
&= \int^\pi_0 \ln (1 - 2(-a^2) \cos x + (-a^2)^2) \, dx\\
&= I(-a^2).
\end{align*}
And since $I$ is even this reduces to
$$I(a) + I(a) = I(a^2),$$
or
$$I(a) = \frac{1}{2} I(a^2). \tag2$$
So by induction on $n \in \mathbb{N}$ we have
$$I(a) = \frac{1}{2} I(a^2) = \frac{1}{2^2} I(a^4) = \frac{1}{2^3} I(a^8) = \cdots = \frac{1}{2^n} I(a^{2^n}). \tag3$$
We can now find the value of $I(a)$ for various values of $a$. 
When $a = 1$, from (2) we have $I(1) = \frac{1}{2} I(1)$ or $I(1) = 0$. Also, since $I(a) = I(-a)$, then $I(1) = I(-1) = 0$. Thus $I(\pm 1) = 0$.
Next, as $n \to \infty$, if $|a| < 1$, $a^{2^n} \to 0$. Thus from (3) we see that $I(a) \to 0$ as $n \to \infty$ for $|a| < 1$. 
Finally, since $I(a) = 0$ for $|a| < 1$, then $I \left (\frac{1}{a} \right ) = 0$ for $|a| > 1$. So from (1) we have $I(a) = 2 \pi \ln |a|$.
So to summarise
$$I (a) = \begin{cases}
0, & |a| \leqslant 1\\[2ex]
2 \pi \ln |a|, & |a| > 1.
\end{cases}
$$
