Evaluate $\int_{0}^{\pi} \log \left(m^2-2m\cos x+1\right)\: dx$ Evaluate $$\int_{0}^{\pi} \log \left(m^2-2m\cos x+1\right)\: dx$$
My Try: I let $$f(m)=\int_{0}^{\pi} \log \left(m^2-2m\cos x+1\right)\: dx$$
Differentiating w.r.t $m$ both sides we get
$$f'(m)=2\int_{0}^{\pi}\frac{(m- \cos x)dx}{(m-\cos x)^2+\sin^2x}=2\int_{0}^{\pi}\frac{(m+ \cos x)dx}{(m+\cos x)^2+\sin^2x}$$
we get
$$f'(m)=2\int_{0}^{\pi}\frac{m \csc^2 x+\csc x \cot x}{(m\csc x+\cot x)^2+1}$$
How to proceed now?
 A: Let's denote the desired integral as$$I(z)=\int\limits_0^{\pi}dx\,\log\left(z^2-2z\cos x+1\right)$$And use Feynman's Trick to turn the integral into something that we can manage. Differentiating with respect to $z$ gives$$I'(z)=\int\limits_0^{\pi}dx\,\frac {2z-2\cos x}{z^2-2z\cos x+1}=\frac 1z\int\limits_0^{\pi}dx\,\left(1-\frac {1-z^2}{z^2-2z\cos x+1}\right)$$The first integral is trivial. The second one can be easily evaluated using a Weierstrass Substitution of $t=\tan\tfrac x2$$$\begin{align*}I'(z) & =\frac {\pi}z-\frac {2(1-z^2)}z\int\limits_0^{\infty}dt\space\frac {1}{\left[t(1+z)\right]^2+(1-z)^2}\\ & =\frac {\pi}z-\frac 2z\left.\arctan\left(\frac {1+z}{1-z}\tan\frac x2\right)\right|_0^{\pi}\end{align*}$$
The expression inside the arctangent function takes on two different values as $x$ varies from zero to $\pi$. When $|z|<1$, the fraction is always positive, even when  $z$ is negative. Therefore, the whole expression evaluates to $\frac {\pi}2$. So$$I'(z)=0\qquad\qquad I(z)=C_1$$
And when $|z|>1$, the fraction is less than zero (can you see why?). So the expression actually evaluates to $-\frac {\pi}2$ and we get a different answer than before$$I'(z)=\frac {2\pi}z\qquad\qquad I(z)=2\pi\log z+C_2$$
To find the two constants, we make a substitution for $z$ that reduces the integral down to something we can easily evaluate. When $|z|<1$, the substitution $z=0$ gives $I(z)=0$, so we immediately see that $C_1=0$.
When $|z|>1$, we first make a substitution $z=\frac 1w$ where $|w|<1$ and use the result previously to get that $C_2$ is also equal to zero. Finally, we're left with
$$\int\limits_0^{\pi}dx\,\log\left(z^2-2z\cos x+1\right)=\left\{\begin{align*}2\pi\log z\qquad |z|>1\\\\0\qquad\space\space\qquad |z|\leq1\end{align*}\right.$$
A: Note that
$$I(m)=\int_{0}^{\pi} \log \left(m^2-2m\cos x+1\right)\: dx=\frac12\int_{0}^{2\pi} \log \left(m^2-2m\cos x+1\right)\: dx $$
and hence
$$I(m)=\frac12\int_0^{2\pi}\frac{2m-2\cos x}{(m^2+1)-2m\cos x}\;dx. $$
Let $z=e^{ix}$ and then
\begin{eqnarray}
I'(m)&=&\frac12\int_0^{2\pi}\frac{2m-2\cos x}{(m^2+1)-2m\cos x}\;dx\\
&=&\frac12\int_{|z|=1}\frac{2m-(z+\frac1z)}{(m^2+1)-m(z+\frac1z)}\;\frac{dz}{iz}\\
&=&\frac1{2i}\int_{|z|=1}\frac{2mz-(z^2+1)}{z\bigg[(m^2+1)z-m(z^2+1)\bigg]}\;dz\\
&=&-\frac1{2mi}\int_{|z|=1}\frac{2mz-(z^2+1)}{z(z-m)(z-\frac1m)}\;dz.
\end{eqnarray}
Let
$$ f(z)=\frac{2mz-(z^2+1)}{z(z-m)(z-\frac1m)}. $$
If $m<1$, then $f(z)$ has two poles $z=0$ and $z=m$ inside $|z|=1$ and hence
$$ I'(m)=-\frac1{2mi}\cdot2\pi i\bigg[\text{Res}\bigg(f(z),z=m\bigg)+\text{Res}\bigg(f(z),z=0\bigg)\bigg]=0 $$
and hence
$$ I(m)=C. $$
Since $I(0)=0$, so $C=0$ and hence $I(m)=0$.
If $m>1$, then $f(z)$ has two poles $z=0$ and $z=\frac1m$ inside $|z|=1$ and hence
$$ I'(m)=-\frac1{2mi}\cdot2\pi i\bigg[\text{Res}\bigg(f(z),z=\frac1m\bigg)+\text{Res}\bigg(f(z),z=0\bigg)\bigg]=\frac{2\pi}{m} $$
and hence
$$ I(m)=2\pi\log m+C. $$
Since $I(1)=0$, so $C=0$ and hence $I(m)=2\pi\log m$.
A: For $|m|<1$, we have
$$ \log(1+m^2-2m\cos x) = \log(1-me^{ix})(1-me^{-ix})
= \log{(1-me^{ix})}+\log(1-me^{-ix}) \\
= -\sum_{k=1}^{\infty} \frac{1}{k}m^k (e^{ikx}+e^{-ikx})
= -2\sum_{k=1}^{\infty} \frac{m^k}{k} \cos{kx}.$$
Thus:
$$ \int_0^\pi\log(1+m^2-2m\cos x) dx=-2\sum_{k=1}^{\infty} \frac{m^k}{k}\int_0^\pi \cos{kx} dx=0.
$$
For $|m|>1$, we can write:
$$
\log(1+m^2-2m\cos x)=\log(1+m^{-2}-2m^{-1}\cos x)+\log m^2,
$$
so that after integration one obtains $\pi \log m^2$.
Thus, finally
$$\int_0^\pi\log(1+m^2-2m\cos x) dx=\begin{cases}
0,& |m|<1,\\
\pi\log m^2,& |m|>1.\\
\end{cases}
$$
