An identity of an Elliptical Integral

Suppose $0<k<1$ and $\displaystyle K(k)=\int_0^1\frac{\mathrm{d}x}{\sqrt{(1-x^2)(1-k^2x^2)}}$. Let $\tilde{k}$ be $\tilde{k}^2=1-k^2$. Show that $$\displaystyle K(k)=\frac{2}{1+\tilde{k}}K\left(\frac{1-\tilde{k}}{1+\tilde{k}}\right)$$

There's a hint in Stein's Complex Analysis which is this change of variable : $x=\dfrac{2t}{1+\tilde{k}+(1-\tilde{k})t^2}$.


For me, the only way I can remember this sort of complicated identities is through the relationship between the complete elliptic integral of the first kind $K(k)$ and the corresponding arithmetic-geometric mean.

$$K(k) = \int_0^\frac{\pi}{2} \frac{d\theta}{\sqrt{1-k^2\sin^2\theta}} = \frac{\pi}{2\text{AGM}( 1, \sqrt{1-k^2})}\tag{*1}$$

Consider following integral

$$I(a,b) = \int_0^{\frac{\pi}{2}} \frac{d\theta}{\sqrt{a^2\cos^2\theta + b^2\sin^2\theta}}$$ Introduce $x = b\tan\theta$, we can rewrite it as

$$I(a,b) = \int_0^{\frac{\pi}{2}} \frac{d\tan\theta}{ \sqrt{(1+\tan^2\theta)(a^2+b^2\tan^2\theta})} = \int_0^\infty \frac{dx}{\sqrt{(x^2 + a^2)(x^2+b^2)}}\tag{*2}$$ Substitute $x$ by $\sqrt{ab} t$, we have $$I(a,b) = \frac{1}{\sqrt{ab}}\int_0^\infty \frac{dt}{\sqrt{t^4 + \left(\frac{a}{b}+\frac{b}{a}\right)t^2 + 1}} = \frac{1}{\sqrt{ab}}\int_0^\infty \frac{1}{\sqrt{ ( t - t^{-1})^2 + \frac{(a+b)^2}{ab}}}\frac{dt}{t} $$ Notice the last integrand is invariant under transform $\displaystyle\;t \leftrightarrow \frac{1}{t}$. If we introduce two more variables $s$ and $y$ such that $$s = \frac12 (t - t^{-1}) = \frac{y}{\sqrt{ab}}$$ and using the fact $$\frac{dt}{t} = \frac{d(t - t^{-1})}{t + t^{-1}} = \frac{ds}{\sqrt{s^2+1}}$$ We can rewrite $I(a,b)$ as $$ \frac{2}{\sqrt{ab}}\int_1^\infty \frac{1}{\sqrt{ ( t - t^{-1})^2 + \frac{(a+b)^2}{ab}}}\frac{dt}{t} = \frac{2}{\sqrt{ab}}\int_0^\infty \frac{ds}{\sqrt{\left(4s^2 + \frac{(a+b)^2}{ab}\right)(s^2+1)}}\\ = \int_0^\infty \frac{dy}{\sqrt{\left(y^2 + \left(\frac{a+b}{2}\right)^2\right)(y^2 + ab)}} $$ Compare this with $(*2)$, we obtain an important identity: $$I(a,b) = I\left(\frac{a+b}{2}, \sqrt{ab}\right)$$ This means $I(a,b)$ is invariant if we replace $(a,b)$ by their AM and GM.

Start with any pair of numbers $a,b$, it is well known if you repeat taking AM/GM of them, the pairs will ultimately converge to a single number. This is called the arithmetic geometric mean of $a$ and $b$ and usually denoted as $\text{AGM}(a,b)$. If one replace $a$, $b$ by this AGM in the definition of $I(a,b)$, we obtain

$$I(a,b) = \frac{\pi}{2\text{AGM}(a,b)}$$

Together with the obvious identity $K(k) = I(1,\sqrt{1-k^2})$, we immediately obtain $(*1)$.

Using these tools and notice $\text{AGM}(a,b)$ is homogenous. i.e.

$$\text{AGM}(\lambda a, \lambda b) = \lambda \text{AGM}(a,b) \quad\implies\quad I(\lambda a, \lambda b) = \frac{1}{\lambda} I(a,b),$$ the desired identity follows immediately.

$$ K(k) = I(1,\tilde{k}) = I\left(\frac{1+\tilde{k}}{2},\sqrt{\tilde{k}}\right) = \frac{2}{1+\tilde{k}} I\left(1,2\frac{\sqrt{\tilde{k}}}{1+\tilde{k}}\right)\\ = \frac{2}{1+\tilde{k}} K\left( \sqrt{1 - \frac{4\tilde{k}}{(1+\tilde{k})^2}} \right) = \frac{2}{1+\tilde{k}} K\left( \frac{1-\tilde{k}}{1+\tilde{k}} \right) $$


$(*)\displaystyle\frac{\mathrm{d}x}{\mathrm{d}t}=2\times\frac{1+\tilde{k}+(1-\tilde{k})t^2-2(1-\tilde{k})t^2}{[1+\tilde{k}+(1-\tilde{k})t^2]^2}=2\frac{1+\tilde{k}-(1-\tilde{k})t^2}{[1+\tilde{k}+(1-\tilde{k})t^2]^2}$.

$(*)\displaystyle\sqrt{1-x^2}=\frac{\sqrt{(1+\tilde{k})^2+(1-\tilde{k})^2t^4+2k^2t^2-4t^2}}{1+\tilde{k}+(1-\tilde{k})t^2}=\frac{\sqrt{(1+\tilde{k})^2+(1-\tilde{k})^2t^4-2\tilde{k}^2t^2-2t^2}}{1+\tilde{k}+(1-\tilde{k})t^2}$.

$(*)\displaystyle\sqrt{1-k^2x^2}=\frac{\sqrt{(1+\tilde{k})^2+(1-\tilde{k})^2t^4+2k^2t^2-4k^2t^2}}{1+\tilde{k}+(1-\tilde{k})t^2}=\frac{\sqrt{(1+\tilde{k})^2+(1-\tilde{k})^2t^4-2k^2t^2}}{1+\tilde{k}+(1-\tilde{k})t^2}$.

Now by reparameterizing the Integral :

$\begin{align*} \displaystyle K(k)&=2\int_0^1\frac{1+\tilde{k}+(1-\tilde{k})t^2}{\sqrt{(1+\tilde{k})^2+(1-\tilde{k})^2t^4-2\tilde{k}^2t^2-2t^2}}. \frac{1+\tilde{k}+(1-\tilde{k})t^2}{\sqrt{(1+\tilde{k})^2+(1-\tilde{k})^2t^4-2k^2t^2}}\\ &\qquad.\frac{1+\tilde{k}-(1-\tilde{k})t^2}{[1+\tilde{k}+(1-\tilde{k})t^2]^2}.\mathrm{d}t\\ &=\frac{2}{1+\tilde{k}}\int_0^1\frac{1}{\sqrt{1+(\frac{1-\tilde{k}}{1+\tilde{k}})^2t^4-\frac{2\tilde{k}^2t^2+2t^2}{\color{red}{(1+\tilde{k})^2}} }}. \frac{1-(\frac{1-\tilde{k}}{1+\tilde{k}})t^2}{\sqrt{1+(\frac{1-\tilde{k}}{1+\tilde{k}})^2t^4+\frac{2\tilde{k}^2t^2-2t^2}{\color{red}{(1+\tilde{k})^2}}}}\mathrm{d}t \end{align*}$

Here is the Complete proof after achille hui's correction:

$\begin{align*} \displaystyle LHS&=\frac{2}{1+\tilde{k}}\int_0^1 \frac{1-(\frac{1-\tilde{k}}{1+\tilde{k}})t^2} {\sqrt{(1-t^2)\left(1-\frac{1-\tilde{k}}{1-\tilde{k}}t^2\right)}.\sqrt{\left(1-(\frac{1-\tilde{k}}{1+\tilde{k}})t^2\right)^2}}\mathrm{d}t\\ &=\displaystyle\frac{2}{1+\tilde{k}}\int_0^1 \frac{\mathrm{d}t} {\sqrt{(1-t^2)\left(1-\frac{1-\tilde{k}}{1-\tilde{k}}t^2\right)}}\\ &=\displaystyle\frac{2}{1+\tilde{k}}K\left(\frac{1-\tilde{k}}{1+\tilde{k}}\right)\tag{QED} \end{align*}$