How to show that $\frac{1}{2\pi} \int_{0}^{2\pi}\ln|re^{i\theta} -a|d\theta=\max(\ln r,\ln|a|)$? In a PDF  I am reading they say:
$$\frac{1}{2\pi} \int_{0}^{2\pi}\ln|re^{i\theta}-a|d\theta=\max(\ln r,\ln|a|). $$
It is certainly a simple calculation but I can't see why. Is there someone who can explain to me. Thanks.
 A: What you are looking for is called Jensen's formula which gives the case when $|a|\neq r$:

Suppose that $f$ is an analytic function in a region in the complex plane which contains the closed disk $D$ of radius $r$ about the origin, $a_1$, $a_2$, ..., an are the zeros of $f$ in the interior of $D$ repeated according to multiplicity, and $f(0) \neq 0$. Jensen's formula states that
  $$
 \log |f(0)| = \sum_{k=1}^n \log \left( \frac{|a_k|}{r}\right) + \frac{1}{2\pi} \int_0^{2\pi} \log|f(re^{i\theta})| \, d\theta.
$$
  This formula establishes a connection between the moduli of the zeros of the function $f$ inside the disk $D$ and the average of $\log |f(z)|$ on the boundary circle $|z| = r$, and can be seen as a generalisation of the mean value property of harmonic functions. Namely, if $f$ has no zeros in $D$, then Jensen's formula reduces to
  $$
 \log |f(0)| = \frac{1}{2\pi} \int_0^{2\pi} \log|f(re^{i\theta})| \, d\theta,
$$
  which is the mean-value property of the harmonic function $ \log |f(z)|$.

When $|a|=r$, there is a singularity for the integrand and I think this case is not used in the linked paper. 
A: Note the following result:

If $|b|\leq 1$, then $$\int_0^{2\pi} \ln|1-be^{i\theta}| d\theta = 0$$

For $|b|< 1$, This can be proven easily by using the taylor expansion of $\ln(1-x)$ because $\int_0^{2\pi} e^{in\theta} d\theta = 0$ for each positive integer $n$. For $|b| = 1$, this follows from a continuity argument (because the integral converges).
This formula immediately implies your result by using $\ln|xy| = \ln|x|+\ln|y|$.
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

$\ds{{1 \over 2\pi}\int_{0}^{2\pi}
\ln\pars{\verts{r\expo{\ic\theta} - a}}\,\dd\theta = \max\braces{\ln\pars{r},\ln\pars{\verts{a}}}:\ {\large ?}.
\qquad a \in \mathbb{C}.}$

Lets $\ds{r = \verts{r}\expo{\ic\phi_{\large r}}}$ and
$\ds{a = \verts{a}\expo{\ic\phi_{\large a}}}$ where
$\ds{\phi_{r}, \phi_{a} \in \left[0,2\pi\right)}$. Note that
\begin{align}
&\bbox[15px,#ffe]{\ds{{1 \over 2\pi}\int_{0}^{2\pi}
\ln\pars{\verts{r\expo{\ic\theta} - a}}\,\dd\theta}}  =
{1 \over 2\pi}\int_{0}^{2\pi}
\ln\pars{\verts{\verts{r}\expo{\ic\pars{\phi_{\large r} + \theta}} - \verts{a}\expo{\ic\phi}}}\,\dd\theta
\\[5mm] & =
{1 \over 2\pi}\int_{0}^{2\pi}
\ln\pars{\verts{\verts{r}
\expo{\ic\pars{\theta + \phi_{\large r}- \phi_{\large a}}} - \verts{a}}}\,\dd\theta =
{1 \over 2\pi}\,\Re\int_{0}^{2\pi}
\ln\pars{\verts{r}\expo{\ic\pars{\theta + \phi_{\large r}- \phi_{\large a}}} - \verts{a}}\,\dd\theta
\\[5mm] = &\
{1 \over 2\pi}\,\Re\oint_{\verts{z}\ =\ \verts{r}}\ln\pars{z - \verts{a}}
\,{\dd z \over \ic z} =
{1 \over 2\pi}\,\Im\oint_{\verts{z}\ =\ \verts{r}}
{\ln\pars{z - \verts{a}} \over z}\,\dd z
\end{align}
I'll consider the branch-cut
$$
\ln\pars{z - \verts{a}} =
\ln\pars{\verts{\vphantom{\Large A}z - \verts{a}}} +
\mrm{arg}\pars{z - \verts{a}}\ic.\qquad
-\pi < \mrm{arg}\pars{z - \verts{a}} < \pi\,,\quad z \not= \verts{a}
$$

$\ds{\Large\verts{a} < \verts{r}:\ {\large ?}.\quad}$
$\ds{\large Note\ that\ r \not= 0}$.
\begin{align}
&{1 \over 2\pi}\int_{0}^{2\pi}
\ln\pars{\verts{r\expo{\ic\theta} - a}}\,\dd\theta
\\[5mm] & \stackrel{\mrm{as}\ \epsilon\ \to\ 0^{+}}{\sim}
{1 \over 2\pi}\,\Im\left[%
-\int_{-\verts{r}}^{\verts{a}}
{\ln\pars{\verts{a} - x} + \ic\pi\over x + \ic\epsilon}\,\dd x -
\int_{\pi}^{-\pi}{\ln\pars{\epsilon} + \ic\theta \over \verts{a}}
\,\epsilon\expo{\ic\theta}\ic\,\dd\theta\right.
\\[2mm] &\ \left.\phantom{\stackrel{\mrm{as}\ \epsilon\ \to\ 0^{+}}{\sim}
{1 \over 2\pi}\,\Im\left[\,\right.}
-\int_{\verts{a}}^{-\verts{r}}{\ln\pars{\verts{a} - x} - \ic\pi \over x - \ic\epsilon}\,\dd x\right]
\\[5mm] \stackrel{\mrm{as}\ \epsilon\ \to\ 0^{+}}{\large \to}\,\,\, &
{1 \over 2\pi}\,\Im\left[%
-\,\mrm{P.V.}\int_{-\verts{r}}^{\verts{a}}
{\ln\pars{\verts{a} - x} + \ic\pi \over x}\,\dd x +
\ic\pi\bracks{-\verts{r} < 0 < \verts{a}}\bracks{\ln\pars{\verts{a}} + \ic\pi}\right. +
\\[2mm] & \phantom{{1 \over 2\pi}\left[-\,\,\,\right.}
\left.\mrm{P.V.}\int_{-\verts{r}}^{\verts{a}}
{\ln\pars{\verts{a} - x} - \ic\pi \over x}\,\dd x +
\ic\pi\bracks{-\verts{r} < 0 < \verts{a}}\bracks{\ln\pars{\verts{a}} - \ic\pi}
\right]
\\[5mm] = &\
-\,\mrm{P.V.}\int_{-\verts{r}}^{\verts{a}}{\dd x \over x} +
\bracks{a \not= 0}\ln\pars{\verts{a}}
\\[5mm] = &\
-\ \underbrace{\mrm{P.V.}\int_{-\verts{r}}^{\verts{r}}{\dd x \over x}}
_{\ds{=\ 0}}\ -\
\int_{\verts{r}}^{\verts{a}}{\dd x \over x} +
\bracks{ar \not= 0}\ln\pars{\verts{a}}
\\[5mm] & =
 -\bracks{a \not = 0}\ln\pars{\verts{a} \over \verts{r}} +
\bracks{a \not = 0}\ln\pars{\verts{a}} = \bracks{a \not= 0}\ln\pars{\verts{r}}
\end{align}

$\ds{\Large\verts{a} > \verts{r}:\ {\large ?}.\quad}$
$\ds{\large Note\ that\ a \not= 0}$.
\begin{align}
&{1 \over 2\pi}\int_{0}^{2\pi}
\ln\pars{\verts{r\expo{\ic\theta} - a}}\,\dd\theta =
\bracks{r \not= 0}{1 \over 2\pi}\,\Im\bracks{2\pi\ic\ln\pars{-a}} =
\bracks{r \not= 0}\ln\pars{\verts{a}}
\end{align}

Then,
$$
\bbox[#ffe,15px,border:1px dotted navy]{\ds{{1 \over 2\pi}\int_{0}^{2\pi}
\ln\pars{\verts{r\expo{\ic\theta} - a}}\,\dd\theta = \max\braces{\ln\pars{r},\ln\pars{\verts{a}}}\,,\qquad ar \not= 0}}
$$
