Derivation of an integral containing the complete elliptic integral of the first kind This is a repost of mathoverflow to draw broader attentions.
https://mathoverflow.net/questions/439770/derivation-of-an-integral-containing-the-complete-elliptic-integral-of-the-first
I found the following formula in "INTEGRALS AND SERIES, vol.3" by Prudnikov, Brychkov and Marichev (page 188, eq.5).
$$\int_0^{\infty} \frac{x^{\alpha-1}}{\sqrt{(a+x)^2+z^2}}K\Bigg(\frac{2\sqrt{ax}}{\sqrt{(a+x)^2+z^2}}\Bigg)dx \\ \quad \quad = \frac{\sqrt{\pi}}{4}\Gamma\Big(\frac{\alpha}{2}\Big)\Gamma\
\Big(\frac{1-\alpha}{2}\Big)(a^2+z^2)^{(\alpha-1)/2}P_{-\alpha}\Bigg(\frac{z}{\sqrt{a^2+z^2}}\Bigg)$$
$K$: complete elliptic integral of the first kind.
$\Gamma$: Gamma function
$P$: Legendre function of the first kind.
$\alpha$: complex value
The book says this is valid for $a>0, \operatorname{Re} z>0, 0 < \operatorname{Re}\alpha<1$. Could anybody tell me how this can be derived ?
I think this formula would be useful for evaluating Mellin transform of a function that contains the complete elliptic integrals.
Thank you in advance.
https://www.researchgate.net/publication/268650078_Integrals_and_Series_Volume_3_More_Special_Functions
 A: Since $\displaystyle K(k)=\int_0^{\pi/2}\frac{d t}{\sqrt{1-k^2\sin^2t}}$,
$$
\begin{align}
&\frac{1}{\sqrt{(a+x)^2+z^2}}K\left(\frac{2\sqrt{ax}}{\sqrt{(a+x)^2+z^2}}\right)
\\ =& \int_0^{\pi/2}\frac{dt}{\sqrt{(a+x)^2+z^2-4ax\sin^2t}}
\\ =& \int_0^{\pi/2}\frac{dt}{\sqrt{a^2+z^2+x^2+2ax\cos2t}}
\\=& \frac14\int_{-\pi}^{\pi}\frac{d\phi}{\sqrt{a^2+z^2+x^2+2ax\cos \phi}}\quad \phi=2t
\end{align}
$$
The integrand is the reciprocal of the distance between $(-x,\pi/2,0)$ and $\left(r=\sqrt{z^2+a^2},\theta=\arctan\dfrac az,\phi\right)$ under spherical coordinate, so one can expand it into series of spherical harmonics, assuming $x$ sufficiently small
$$
\frac1{\sqrt{a^2+z^2+x^2+2ax\cos \phi}}=\sum_{l\ge0}\frac{(-x)^l}{r^{l+1}}\sum_{m=-l}^l(-1)^mP_l^{-m}(0)P_l^{m}(\cos\theta)e^{ i m\phi}
$$
Perform the integral over $\phi$ and only the terms with $m=0$ remains, so
$$
\int_{-\pi}^{\pi}\frac{d\phi}{\sqrt{a^2+z^2+x^2-2ax\cos \phi}}=2\pi\sum_{l\ge0}\frac{(-x)^l}{r^{l+1}}P_l(0)P_l(\cos\theta)
$$
Now use Ramanujan's Master Theorem with
$$
\varphi(l)=\frac\pi2\frac{1}{r^{l+1}}P_l(0)P_l(\cos\theta)
$$
$$
\mathcal M\left(\frac{\pi}2\sum_{l\ge0}\frac{x^l}{r^{l+1}}P_l(0)P_l(\cos\theta)\right)(s)=\frac\pi{\sin\pi s}\varphi(-s)\\
=\Gamma(s)\Gamma(1-s)\cdot\frac\pi2\frac{1}{r^{1-s}}P_{-s}(0)P_{-s}(\cos\theta)
$$
Finally, recall the special value of Legendre function
$$
P_{\nu}(0)=\frac{\sqrt{\pi }}{\Gamma \left(\frac{1-\nu}{2}\right) \Gamma \left(\frac{\nu }{2}+1\right)}
$$
and the duplication formula of Gamma function. After a little algebra, substitute$r=\sqrt{a^2+z^2},\cos\theta=\frac{z}{\sqrt{a^2+z^2}}$ and the result follows.
