Integral results in difference of means $\pi(\frac{a+b}{2} - \sqrt{ab})$ $$\int_a^b \left\{ \left(1-\frac{a}{r}\right)\left(\frac{b}{r}-1\right)\right\}^{1/2}dr = \pi\left(\frac{a+b}{2} - \sqrt{ab}\right)$$
What an interesting integral! What strikes me is that the result involves the difference of the arithmetic and geometric mean. Is there an innate geometric explanation that corresponds to this result? And can we generalize this integral to, say, the mean of three or more items?

Some background on where I saw it and how to solve it. This arises in calculating the action variable $I$ for the Kepler problem (Hamiltonian $H=\frac{p_r^2}{2m}+\frac{p_\phi^2}{2mr}-\frac{k}{r}$). The $a,b$ are the minimal and maximal $r$ from the origin set at the focus of an ellipse (i.e. the perihelion/aphelion). See David Tong's Classical Dynamics notes $\S$4.5.4.
I was able to solve the integral by using the third Euler substitution, letting
$$\left\{ \left(1-\frac{a}{r}\right)\left(\frac{b}{r}-1\right)\right\}^{1/2}=\frac{1}{r}\sqrt{-(r-a)(r-b)}=\frac{1}{r}(r-a)t$$
giving $r=\frac{b+at^2}{1+t^2}$ and
$$2(b-a)\left\{\int_{t(r_2)=0}^{t(r_1)=\infty}\frac{t^2}{(1+t^2)^2}dt - \int_{t(r_2)=0}^{t(r_1)=\infty}\frac{\frac{a}{b}t^2}{(1+t^2)(1+\frac{a}{b}t^2)}dt\right\}$$
$$=\pi\left(\frac{b-a}{2}\right) + \pi\left(a-\sqrt{ab}\right)=\pi\left(\frac{a+b}{2} - \sqrt{ab}\right).$$

Let 
$0\le a\le b,$
then
\begin{align}
&I_1 = \int\limits_a^b \left\{ \left(1-\frac{a}{r}\right)\left(\frac{b}{r}-1\right)\right\}^{-1/2}\,\mathrm dr = \int\limits_a^b \dfrac{r}{\sqrt{(r-a)(b-r)}}\,\mathrm dr\\
&=\dfrac12\int\limits_a^b \dfrac{2r-(a+b)}{\sqrt{(r-a)(b-r)}}\,\mathrm dr+\dfrac{a+b}2\int\limits_a^b \dfrac{a+b}{\sqrt{(r-a)(b-r)}}\,\mathrm dr\\
&=-\dfrac12\int\limits_a^b \dfrac{\mathrm d((r-a)(b-r))}{\sqrt{(r-a)(b-r)}} + \dfrac{a+b}2\int\limits_a^b \dfrac{\mathrm dr}{\sqrt{\left(\dfrac{b-a}2\right)^2-\left(r-\dfrac{b+a}2\right)^2}}\\
&=-\sqrt{(r-a)(b-r)}\Bigg|_a^b + \dfrac{a+b}2\arcsin\dfrac{2r-(b+a)}{b-a}\Bigg|_a^b = \pi\dfrac{a+b}2,\\
&I_2 = \int\limits_a^b \left\{ \left(1-\frac{a}{r}\right)\left(\frac{b}{r}-1\right)\right\}^{-1/2}\left(1-\left\{ \left(1-\frac{a}{r}\right)\left(\frac{b}{r}-1\right)\right\}\right)\,\mathrm dr\\
& = \int\limits_a^b \dfrac{2r^2-(a+b)r+ab}{\sqrt{(r-a)(b-r)}}\,\dfrac{\mathrm dr}r = \int\limits_a^b \dfrac{2r-(a+b)}{\sqrt{(r-a)(b-r)}}\,\mathrm dr -  ab\int\limits_a^b \dfrac{1}{\sqrt{(1-\frac ar)(\frac br-1)}}\,\mathrm d\left(\dfrac1r\right)\\
&=-\sqrt{(r-a)(b-r)}\Bigg|_a^b + ab\int\limits_{1/b}^{1/a}\dfrac{\mathrm dt}{\sqrt{(1-at)(bt-1)}}  = \sqrt{ab}\int\limits_{1/b}^{1/a}\dfrac{\mathrm dt}{\sqrt{(\frac1a-t)(\frac1b-t)}}\\ 
&= \sqrt{ab}\int\limits_{1/b}^{1/a}\dfrac{\mathrm dt}{\sqrt{\left(\frac{\frac1a-\frac1b}2\right)^2 - \left(t-\frac{\frac1a+\frac1b}2\right)^2}} = \sqrt{ab}\arcsin\dfrac{{2t-\left(\frac1a+\frac1b\right)}}{{\frac1a-\frac1b}}\Biggr|_{1/b}^{1/a} = \pi ab.\\
\end{align}
This allows to present the issue integral (or the square under the graph of the according function) as the square between two other similar functions, which present AM and GM of $a$ and $b$ (see also Wolphram Alpha plot).

