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