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.

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.$$
