<s>[INST] Legendre relations for elliptic integrals with null imaginary part I am trying to compute the transformation of $K(k)$ as $k \to 1/k$, where $K(k)$ is just the Legendre integral
$$K(k) := F\left(\frac{\pi}{2}, k\right).$$
The Digital Library of Mathematical Functions [1] gives a relation for this transformation that relies on the imaginary part of $k$:
$$K\left(1 / k^{\prime}\right)=k^{\prime}\left(K\left(k^{\prime}\right) \mp \mathrm{i} K(k)\right),$$
where $k^{\prime}$ is the complementary modulus of $k$, and the $\pm$ sign is for $\Im(k) \lessgtr 0$. My question is, how do I find the transformation in the case where $\Im(k)=0$? I understand that there is a branch cut for this formula for $\Im(k)=0$, but what do I do to get around that?
 [/INST] Let $0<k<1$, then
$$ K\left(\frac{1}{k}\right) = \int_{0}^{1}\frac{dt}{\sqrt{\left(1-t^2\right)\left(1-\frac{1}{k^2}t^2\right)}}dt  $$
Make the following change of variable: $\displaystyle w^2 \mapsto \frac{1}{k^2}t^2$
$$K\left(\frac{1}{k}\right) = k\int_{0}^{\frac{1}{k}}\frac{dt}{\sqrt{\left(1-k^2w^2\right)\left(1-w^2\right)}}dw$$
Note that, since $0<k<1$ then $\displaystyle \frac{1}{k}>1$. Hence,
$$K\left(\frac{1}{k}\right)  = k\int_{0}^{1}\frac{dt}{\sqrt{\left(1-k^2w^2\right)\left(1-w^2\right)}}dw + k\int_{1}^{\frac{1}{k}}\frac{dt}{\sqrt{\left(1-k^2w^2\right)\left(1-w^2\right)}}dw$$
The firts integral is just $K(k)$
Then
$$K\left(\frac{1}{k}\right)  = kK(k) + k\int_{1}^{\frac{1}{k}}\frac{dt}{\sqrt{\left(1-k^2w^2\right)\left(1-w^2\right)}}dw$$
For the second, make the substitution:
$$ w = \frac{1}{\sqrt{1-k'^2z^2}}$$
where $k'$ is the complementary modulus and $k' = \sqrt{1-k^2}$
Hence
$$ dw = \frac{k'^2zdz}{\sqrt{1-k'^2z^2}}$$
$$\frac{1}{\sqrt{1-k^2w^2}} = \frac{\sqrt{1-k'^2z^2}}{k'\sqrt{1-z^2}}$$
$$ \frac{1}{\sqrt{1-w^2}} = \frac{i\sqrt{1-k'^2z^2}}{k'z}$$
$$ z \to 0 \textrm{ if } x \to 1$$
$$ z \to 1 \textrm{ if } x \to \frac{1}{k}$$
Therfore
$$\int_{1}^{\frac{1}{k}}\frac{dt}{\sqrt{\left(1-k^2w^2\right)\left(1-w^2\right)}}dw = i\int_{0}^{1}\frac{dt}{\sqrt{\left(1-z^2\right)\left(1-k'^2z^2\right)}}dz= iK(k') $$
Hence, we can conclude
$$ \boxed{K\left(\frac{1}{k}\right) = k\left[K(k)+iK(k')\right] \quad 0<k<1 }$$
</s>