How to compute the following definite integral Studying some integral table, I came across the following definite integral
$$\int_0^{\pi} \log [ a^2 + b^2 -2 a b \cos \phi ]\,d\phi$$ for $a,b \in \mathbb{R}$. Does somebody know a nice way to get the results?
 A: Here is a different way, and is strangely the first thing that came to my mind.  It uses generating series, and power series as well as other various techniques:
(Warning!: It is significantly more complicated)
Assume that $a\geq b\geq0$ without loss of generality.  Notice that our integral is $$\pi \log(a^2+b^2)+\int_{0}^{\pi}\log\left( 1-\frac{2ab\cos\phi}{a^2+b^2}\right). $$ Since $\log(1-x)=-\sum_{i=1}^{\infty}\frac{x^{i}}{i}$ we have 
$$\int_{0}^{\pi}\log\left( 1-\frac{2ab\cos\phi}{a^2+b^2}\right)d\phi=-\int_{0}^{\pi}\sum_{i=1}^{\infty} \frac{1}{i}\left(\frac{2ab\cos\phi}{a^2+b^2}\right)^i d\phi$$
Switch the order or integration and summation to find:  (More on why this is legal at the end)
$$-\int_{0}^{\pi}\sum_{i=1}^{\infty} \frac{1}{i}\left(\frac{2ab\cos\phi}{a^2+b^2}\right)^i d\phi=-\sum_{i=1}^{\infty} \frac{1}{i}\left(\frac{2ab}{a^2+b^2}\right)^i \int_{0}^{\pi} \cos^i\phi d\phi$$
For $n$ odd we have $\int_0^\pi \cos^n xdx=0$.  For even $n=2r$ we see by integration by parts that $\int_{0}^{\pi}\cos(x)^{2r}dx=\frac{2r-1}{2r}\int_{0}^{\pi}\cos(x)^{2r-2}dx$, so that induction yields $$\int_{0}^{\pi}\cos(x)^{2r}dx=\pi\prod_{i=1}^{r}\frac{2i-1}{2i}=\pi\frac{\left({2r\atop r}\right)}{4^{r}}$$
Thus our sum becomes 
$$-\pi \sum_{r=1}^{\infty} \frac{1}{2r}\left(\frac{ab}{a^2+b^2}\right)^{2r} \left({2r\atop r}\right ) $$
Now let $$f(z)=\sum_{r=1}^{\infty} \frac{1}{r} \left({2r\atop r}\right) \frac{z^r}{4^r}$$
Then we need to find $-\frac{\pi}{2} f\left(\left( \frac{2ab}{a^2+b^2} \right)^2\right)$.
Let $Y=\left( \frac{2ab}{a^2+b^2} \right)^2$.
Recall the generating series $$\sum_{n=0}^{\infty}\left({2n\atop n}\right)x^{n}=\frac{1}{\sqrt{1-4x}}. $$  Differentiating yields $1+xf^{'}(x)=\frac{1}{\sqrt{1-x}}$ and hence $f(Y)=\int_{0}^{Y}\frac{1-\sqrt{1-x}}{x\sqrt{1-x}}dx$.
Make the substitution $x=\sin^{2}(u)$, and we get $$f(Y)=\int_{0}^{\theta}\frac{1-\cos(u)}{\sin^{2}(u)\cos(u)}2\sin(u)\cos(u)du=2\int_{0}^{\theta}\csc(u)-\cot(u)du$$ where $\theta$ is in the first quadrant and satisfies $\sin (\theta)=\frac{2ab}{a^2+b^2}.$  
Then since $\int\csc x\, dx=-\log\left|\csc x+\cot x\right|$, and $\int\cot x dx=\log\left|\sin x\right|$, we see that $\int\csc(u)-\cot(u)du=-\log|\sin(u)\csc(u)+\sin(u)\cot u|=-\log|1+\cos(u)|$. Thus $$f(Y)=-2\log|1+\cos(u)|\biggr|_{u=0}^{u=\theta}$$
Drawing the triangle with sides $2ab$, $a^2-b^2$ and $a^2+b^2$ tells us that $\cos(\theta)=\frac{a^2-b^2}{a^2+b^2}$, and hence $$f(Y)=2\log 2- 2\log \left(1+\frac{a^2-b^2}{a^2+b^2}\right)$$
Thus the final answer is  $$\pi \log(a^2+b^2)-\frac{\pi}{2}f(Y)=\pi\log(a^2+b^2)-\pi \log 2 +\pi\log\left(1+\frac{a^2-b^2}{a^2+b^2}\right)=2\pi\log(a)$$
A: Note that by symmetry we can assume $|b| \geq |a|$. Since $\cos(\phi)$ is even, your integral is half of the integral from $-\pi$ to $\pi$, or 
$${1 \over 2}\int_{-\pi}^{\pi} \log(a^2 + b^2 - 2ab\cos(\phi))\,d\phi$$
Note that $|a^2 + b^2 - 2ab\cos(\phi)|$ is the same as $|ae^{i\phi} - b|^2$, so your integral becomes 
$$\int_{-\pi}^{\pi}\log|ae^{i\phi} - b|\,d\phi$$
Thinking of $ae^{i\phi}$ as a complex number $z$, the integrand is the real part of the function $\ln(az - b)$, which is analytic on the interior of the unit disk (we use that $|b| \geq |a|$). Thus the integrand is harmonic and therefore satisfies the mean-value property: the integral over the unit circle is $2\pi$ times the value at the center of the circle, which is $\log|a0 - b| = \log|b|$ in this case. So your answer is $2\pi\log|b|$, which is the same as $2\pi\max(\log|a|,\log|b|)$ since we assume $|b| \geq |a|$.
Technical point: we glossed over applying the mean-value property when $|b| = |a|$ and thus the integrand has a singularity at the boundary; but any of a number of limiting techniques will deal with this case as well.
A: This is Gauss' law in two dimensions in disguise. In two dimensions, the Green's function of the Poisson equation is $\ln r$, so since the argument of the logarithm is the distance between two points at distances $a$ and $b$ from the center with an angle $\phi$ between their vectors, you're calculating the potential between a point charge and a uniformly charged circle, which, since the potential solves the Poisson equation, depends only on the outer radius and is the same as the potential in the case where the charge of the circle is concentrated at its centre.
