Computing $\int_{0}^{\pi}\ln\left(1-2a\cos x+a^2\right) \, dx$

Here is an elementary way to compute the integral.

First, let us prove some initial results.

  1. Making the substitution $x \mapsto \pi - x$ yields $I(a) = \int^\pi_0 \log \left (1 + 2a\cos x + a^2 \right ) \, dx = I(-a)$ so that $$I(a) = I(-a). \tag{$\dagger$}$$

  2. Then, consider $$\begin{align*} I(a) + I(-a) &= \int^{\pi}_{0}\log \! \Big ( \left (1 - 2a\cos x + a^2 \right ) \left (1 + 2a\cos x + a^2 \right ) \Big) \> dx\\ &= \int^{\pi}_{0}\log \! \Big ( \left (1 + a^2 \right )^2 - \left (2a\cos x \right )^2 \Big) \> dx.\\ \end{align*}$$ Using double angle formulae produces $$\begin{align*} I(a) + I(-a)&= \int^{\pi}_{0}\log \left ( 1 + 2a^2 + a^4 - 2a^2 \left ( 1 + \cos 2x \right ) \right) \, dx\\ &= \int^{\pi}_{0}\log \left ( 1 - 2a^2\cos 2x + a^4 \right) \, dx,\\ \end{align*}$$ so we may let $x \mapsto \frac{1}{2}x$ to give $$\begin{align*} I(a) + I(-a) &= \frac{1}{2}\int^{2\pi}_{0}\log \left ( 1 - 2a^2\cos x + a^4 \right) \, dx.\\ \end{align*}$$ We can then split the integral at $\pi$ and set $x \mapsto 2\pi - x$ for the second integral: $$\begin{align*} I(a) + I(-a) &= \frac{1}{2} I(a^2) + \frac{1}{2}\int^{2\pi}_{\pi}\log \left ( 1 - 2a^2\cos x + a^4 \right) \, dx\\ &= \frac{1}{2} I(a^2) + \frac{1}{2}\int^{\pi}_{0}\log \left ( 1 - 2a^2\cos x + a^4 \right) \, dx\\ &= I(a^2). \end{align*}$$ We thus have (applying $(\dagger)$) $$I(a)= \frac{1}{2}I(a^2). \tag{$\star$}$$


It follows from $(\star)$ that $I(0) = 0$ and $I(1) = 0$.

Consider the case when $0 \le a < 1$. We may use $(\star)$ iteratively $n$ times to write

$$I(a) = \frac{1}{2^n} I \left ( a^{2^{n}} \right ). $$

Setting $n \to \infty$ allows $\frac{1}{2^n} \to 0$ and $a^{2^{n}} \to 0$ so that $I \left ( a^{2^{n}} \right ) \to 0$ which gives the result

$$ I(a) = 0. $$

When $a > 1$, it follows that $0 < 1/a < 1$ and consequently $I(1/a) = 0$. We have

$$\begin{align*} I(a) &= \int^\pi_0 \log \! \Big ( a^2 \left ((1/a)^2 + (1/a)\cos x + 1 \right ) \Big ) \> dx\\ &= 2\pi\log(a) + I(1/a)\\ &= 2\pi\log\left(a\right). \end{align*}$$

We could use $(\dagger)$ to extend the result to negative $a$, obtaining the final solution valid for all real $a$,

$$I(a) = \begin{cases} 0 &\text{if } |a| \le 1;\\ 2\pi\log|a| &\text{otherwise}. \end{cases}$$


Considering the following diagram:

$\hspace{2cm}$enter image description here

we get that $$ \begin{align} \int_0^\pi\log\left(1-2r\cos(\theta)+r^2\right)\,\mathrm{d}\theta &=\int_0^{2\pi}\log\sqrt{1-2r\cos(\theta)+r^2}\,\mathrm{d}\theta\\ &=\mathrm{Re}\left(\int_\gamma\log(z-1)\frac{\mathrm{d}z}{iz}\right) \end{align} $$ along the path $\gamma=r\,e^{i[0,2\pi]}$.

If $r\le1$, the singularity at $z=0$ has residue $0$. Thus, the integral is $0$.

If $r\gt1$, then we need to modify the path to avoid the branch cut for $\log(z-1)$ along $\{t\in\mathbb{R}:t\ge1\}$. That is, in addition to the circular contour $\gamma=r\,e^{i[0,2\pi]}$, we need to follow the two contours $[r,1]$ below the real axis and $[1,r]$ above the real axis. The sum of the integrals along these two contours is $$ \int_r^12\pi i\frac{\mathrm{d}z}{iz}+\int_1^r0\frac{\mathrm{d}z}{iz}=-2\pi\log(r) $$ Since the integral along all three contours is $0$, the integral along the circular part must be $2\pi\log(r)$.

Putting these two cases together, we get $$ \int_0^\pi\log\left(1-2r\cos(\theta)+r^2\right)\,\mathrm{d}\theta =\left\{\begin{array}{l} 0&\text{if }r\le1\\ 2\pi\log(r)&\text{if }r\gt1 \end{array}\right. $$