A question in Complex Analysis $\int_0^{2\pi}\log(1-2r\cos x +r^2)\,dx$ My problem is to integrate this expression: 
$$\int_0^{2\pi}\log(1-2r\cos x +r^2)dx.$$
where $r$ is any constant in $[0,1]$.
I know the answer is zero. Can you explain you idea to me or just prove that?
Maybe you will use the "Cauchy integral theorem ".
 A: Edit: I have proved a little more. Namely, this integral is $0$ for $| r|\leq 1$, and $4\pi\log|r|$ for $|r|\geq 1$.
1) If $r=0$, this is $0$. 
2) Now assume $0< r\leq 1$. We have
$$
1-2r\cos x+r^2=(1-re^{ix})(1-re^{-ix})=|1-re^{ix}|^2.
$$
Hence the integral can be written
$$
2\int_0^{2\pi}\log |1-re^{ix}|dx=4\pi\cdot \frac{1}{2\pi} \int_0^{2\pi}\log |1-re^{ix}|dx=
\frac{2}{i}\int_{\gamma_r}\frac{\log|1-z|}{z}dz.
$$
where $\gamma_r(x)=re^{ix}$ over $[0,2\pi]$, i.e. $\gamma_r$ is the circle of radius $r$ centered at $0$.
Shortcut: as pointed out by robjohn, $\log|1-z|=\mbox{Re}\;\log(1-z)$, so we can conclude by Cauchy's integral formula. I'll leave my harmonic argument below.
Recall that if $f$ is holomorphic, then $\log|f|$ is harmonic on its domain. So $$g:z\longmapsto \log|1-z|$$ is harmonic on the open unit disk $D=\{z\in\mathbb{C}\;;\;|z|<1\}$. 
If $0<r<1$, then the circle $\gamma_r$ is contained in $D$ and contains $0$, so 
$$
0=g(0)=\frac{1}{2\pi} \int_0^{2\pi}g(re^{ix})dx=\frac{1}{2\pi} \int_0^{2\pi}\log |1-re^{ix}|dx
$$
by the mean value property of harmonic functions.
3) For $r=1$ now. Fix $x$ and study the variations of $r\longmapsto \log(1-2r\cos x+r^2)$ on $[0,1]$. If $\cos x\leq 0$, this is increasing and nonnegative, so $|\log(1-2r\cos x+r^2)|\leq \log(1-2\cos x+1)$. And if $\cos x\geq 0$, it is nonpositive with a minimum at $r=\cos x$, so $|\log(1-2r\cos x+r^2)|\leq| \log(1-2\cos^2 x+\cos^2 x)|=| \log(\sin^2 x)|$. In any case, we see  that the integrand is uniformly bounded by an integrable function. It follows that 
$$
\int_0^{2\pi}\log(1-2\cos x+1)dx=\lim_{r\rightarrow 1^-} \int_0^{2\pi}\log(1-2r\cos x+r^2)dx=0
$$
by Lebesgue dominated convergence.
So these integrals are $0$ for every $0\leq r\leq 1$.
4) By change of variable and periodicity, we get $0$ for $-1\leq r\leq 1$. 
5) Finally, for $|r|>1$, we get
$$
\int_0^{2\pi}\log(1-2r\cos x+r^2)dx=\int_0^{2\pi}\log\left(r^2\left(\frac{1}{r^2}-2\frac{1}{r}\cos x+1\right)\right)dx
$$
$$
=\int_0^{2\pi}\log r^2dx+ \int_0^{2\pi}\log\left(\frac{1}{r^2}-2\frac{1}{r}\cos x+1\right)dx=4\pi \log |r|+0.
$$
A: Note that
$$
\begin{align}
\int_0^{2\pi}\log(1-2r\cos(x)+r^2)\,\mathrm{d}x
&=2\,\mathrm{Re}\left(\oint_\gamma\log(1-z)\frac{\mathrm{d}z}{iz}\right)
\end{align}
$$
where the contour of integration is $\gamma(x)=re^{ix}$.
Since there is no singularity inside the contour, the integral is $0$.
A: Copying from my blog.
Let $$I(a) = \displaystyle \int_0^{\pi} \ln \left(1-2a \cos(x) + a^2\right) dx$$ Some preliminary results on $I(a)$. Note that we have $$I(a) = \underbrace{\displaystyle \int_0^{\pi} \ln \left(1+2a \cos(x) + a^2\right) dx}_{\spadesuit} = \overbrace{\dfrac12 \displaystyle \int_0^{2\pi} \ln \left(1-2a \cos(x) + a^2\right) dx}^{\clubsuit}$$ $(\spadesuit)$ can be seen by replacing $x \mapsto \pi-x$ and $(\clubsuit)$ can be obtained by splitting the integral from $0$ to $\pi$ and $\pi$ to $2 \pi$ and replacing $x$ by $\pi+x$ in the second integral.
Now let us move on to our computation of $I(a)$.
\begin{align}
I(a^2) & = \int_0^{\pi} \ln \left(1-2a^2 \cos(x) + a^4\right) dx = \dfrac12 \int_0^{2\pi} \ln \left(1-2a^2 \cos(x) + a^4\right) dx\\
& = \dfrac12 \int_0^{2\pi} \ln \left((1+a^2)^2-2a^2(1+ \cos(x))\right) dx = \dfrac12 \int_0^{2\pi} \ln \left((1+a^2)^2-4a^2 \cos^2(x/2)\right) dx\\
& = \dfrac12 \int_0^{2\pi} \ln \left(1+a^2-2a \cos(x/2)\right) dx + \dfrac12 \int_0^{2\pi} \ln \left(1+a^2+2a \cos(x/2)\right) dx
\end{align}
Now replace $x/2=t$ in both integrals above to get
\begin{align}
I(a^2) & = \int_0^{\pi} \ln \left(1+a^2-2a \cos(t)\right) dt + \int_0^{\pi} \ln \left(1+a^2+2a \cos(t)\right) dt = 2I(a)
\end{align}
Now for $a \in [0,1)$, this gives us that $I(a) = 0$. This is because we have $I(0) = 0$ and $$I(a) = \dfrac{I(a^{2^n})}{2^n}$$ Now let $n \to \infty$ and use continuity to conclude that $I(a) = 0$ for $a \in [0,1)$. Now lets get back to our original problem. Consider $a>1$. We have
\begin{align*}
I(1/a) & = \int_0^{\pi} \ln \left(1-\dfrac2{a} \cos(x) + \dfrac1{a^2}\right)dx\\
& = \int_0^{\pi} \ln(1-2a \cos(x) + a^2) dx - 2\int_0^{\pi} \ln(a)dx\\
& = I(a) - 2 \pi \ln(a)\\
& = 0  \tag{Since $1/a < 1$, we have $I(1/a) = 0$}
\end{align*}
Hence, we get that
$$I(a) = \begin{cases} 2 \pi \ln(a) & a \geq 1 \\ 0 & a \in [0,1] \end{cases}$$
A: An idea: putting
$$z:=re^{ix}:=r\cos x+i\,r\sin x\;,\;\;r,x\in\Bbb R\implies dz=rie^{ix}dx\;,\;\; 1-2r\cos x+r^2=|z-1|^2$$
so by an extension to Cauchy's Integral Formula from the MVHF (see Note and comments below) we get
$$\int\limits_0^{2\pi}\log(1-2r\cos x+r^2)dx=\frac{2}{i}\int\limits_{S^1}\frac{\log|z-1|}{z}dz=4\pi\left(\log|z-1|\right)_{z=0}=0$$
Note: In fact the result follows at once from the Mean Value Property for Harmonic Functions (see comments below and Julien's answer), which can be seen as a "special" kind of extension or, perhaps more accurate, special case of the CIF. Follow the links below and above
