Proving that $ \int_{0}^{\pi/2} \frac{\mathrm{d}{x}}{\sqrt{a^{2} {\cos^{2}}(x) + b^{2} {\sin^{2}}(x)}} = \frac{\pi}{2 \cdot \text{AGM}(a,b)} $. I know Neumann’s solution of this famous definite integral that is totally based on substitution, but is there any solution using complex analysis? Assuming that $ a > b $, show that
$$
  \int_{0}^{\pi/2} \frac{\mathrm{d}{x}}{\sqrt{a^{2} {\cos^{2}}(x) + b^{2} {\sin^{2}}(x)}}
= \frac{\pi}{2 \cdot \text{AGM}(a,b)},
$$
where $ \text{AGM}(a,b) $ is the arithmetic-geometric mean of $ a $ and $ b $, which satisfies the following functional equation:
$$
\text{AGM}(a,b) = \text{AGM} \! \left( \frac{a + b}{2},\sqrt{a b} \right).
$$

Let
$$I(a,b)=\int_{0}^{\pi/2}\frac{dx}{\sqrt{a^2\sin^2 x+b^2\cos^2 x}}=\int_{0}^{1}\frac{dt}{\sqrt{(1-t^2)(a^2 t^2 + b^2(1-t^2))}}.\tag{1}$$
Obviously $I(a,a)=\frac{\pi}{2a}$, hence in order to prove our identity we just need to prove that:
$$ I(a,b)=I\left(\sqrt{ab},\frac{a+b}{2}\right).\tag{2}$$
By replacing $b\tan x$ with $z$, we have:
$$ I(a,b) = \int_{0}^{\infty}\frac{dz}{\sqrt{(z^2+a^2)(z^2+b^2)}}.\tag{3}$$
By Lagrange's identity for multiplying the sums of two squares,
$$ (z^2+a^2)(z^2+b^2) = (z^2-ab)^2+(a+b)^2 z^2, \tag{4} $$
hence, with the substitution $z=\frac{1}{2}\left(u-\frac{ab}{u}\right)$, $(3)$ turns into
$$ \int_{0}^{\infty}\frac{du}{\sqrt{\left(u^2+\frac{1}{4}(a+b)^2\right)(u^2+ab)}}=I\left(\sqrt{ab},\frac{a+b}{2}\right),$$
so we're done, since $I(a,b)$ is a continuous function with respect to its parameters and the iterates of the map $\varphi:(a,b)\to\left(\sqrt{ab},\frac{a+b}{2}\right)$ converge towards $\left(\text{AGM}(a,b),\text{AGM}(a,b)\right)$ giving:
$$ I(a,b)=\frac{\pi}{2\cdot\text{AGM}(a,b)} $$ 
as wanted.
