Evaluate $\int_0^{\frac{\pi}{2}} \frac{1}{\sqrt{1+k^2 \sin^2 \theta}} \,d \theta$ 
Evaluate $\int_0^{\frac{\pi}{2}} \frac{1}{\sqrt{1+k^2 \sin^2\theta}}
 \,d \theta$

I wang to let  $k=-ai \,\,\,\,\,$ ,then :$$\int_0^{\frac{\pi}{2}} \frac{1}{\sqrt{1-a^2 \sin^2\theta}}
 \,d \theta$$
But I am not sure whether the elliptic integral can be used when $k$ is complexed.Or is it right that the Taylor expansion of $(1-z)^{-\frac{1}{2}} $ an analogue of $(1-x)^{-\frac{1}{2}} $
 A: The following manipulations assume $k^2<1$. Since for any $x\in(-1,1)$ we have
$$ \frac{1}{\sqrt{1-x}}=\sum_{n\geq 0}\frac{1}{4^n}\binom{2n}{n} x^n \tag{1}$$
and the central binomial coefficients also appear in
$$ \int_{0}^{\pi/2}\sin^{2n}(\theta)\,d\theta = \frac{\pi}{2\cdot 4^n}\binom{2n}{n}\tag{2} $$
by Maclaurin series and termwise integration it follows that
$$\begin{eqnarray*} \int_{0}^{\pi/2}\frac{d\theta}{\sqrt{1+k^2\sin^2\theta}} &=& \frac{\pi}{2}\sum_{n\geq 0}\left[\frac{1}{4^n}\binom{2n}{n}\right]^2(-1)^n k^{2n}=K(-k^2)\\&=&\frac{\pi}{2\,\text{AGM}(1,\sqrt{1+k^2})}\tag{3} \end{eqnarray*}$$
where the complete elliptic integral of the first kind is denoted according to Mathematica's notation (in order to avoid a proliferation of square roots, it is more practical to assume that the argument of $K$ is the elliptic modulus rather than the elliptic parameter). So your integral is given by a hypergeometric $\phantom{}_2 F_1$ function, whose numerical computation is made extremely simple by the relation to the arithmetic-geometric mean.
If $k^2\geq 1$ we may consider that
$$ \int_{0}^{\pi/2}\frac{d\theta}{\sqrt{1+k^2\sin^2\theta}} =\int_{0}^{\pi/2}\frac{d\theta}{\sqrt{1+k^2\cos^2\theta}}=\int_{0}^{\pi/2}\frac{d\theta}{\sqrt{(1+k^2)-k^2\sin^2\theta}}$$
equals
$$\frac{1}{\sqrt{1+k^2}} K\left(\frac{k^2}{k^2+1}\right) = \frac{\pi}{2\sqrt{1+k^2}\text{AGM}\left(1,\sqrt{\frac{1}{k^2+1}}\right)}=\color{red}{\frac{\pi}{2\,\text{AGM}(1,\sqrt{1+k^2})}},$$
so the representation through the $\text{AGM}$ is left unchanged. It gives
$$\frac{\pi}{1+\sqrt{1+k^2}}<\int_{0}^{\pi/2}\frac{d\theta}{\sqrt{1+k^2\sin^2\theta}}<\frac{\pi}{2(1+k^2)^{1/4}}.\tag{4}$$
For particular values of $k$ (like $k=1$) the middle integral has an explicit representation in terms of the $\Gamma$ function evaluated at multiples of $\frac{1}{24}$, see Wikipedia.
If $k$ takes complex values we have to be careful in managing the determinations of the involved square roots, but the mechanics stays pretty much the same.
