Evaluation of complete elliptic integral of second kind I am currently working to try and solve the integral:
$$\int_{0}^{\frac{\pi}{2}} \sqrt{1-a^2\cos(x)^2} = \sqrt{1-a^2} \; E\left ( 1+\frac{1}{-1+a^2} \right )$$ 
where $E(m)$ is the complete elliptic integral of second kind with the parameter $m=k^2$  and $0<a<1$.
This is the soultion I found using WolframAlpha
In this case $m$ is always smaller then $0$, yet $m$ is supposed to be the square of some $k$. 
The implementation I found in NumericalRecipies seems to only accept $k$ as argument, evident through a test, plotting values of the positive argument-branch and comparing them with WolframAlphas elliptic function. 
However, the NR implementation doesn't use any sort of complex variables (therefor, won't accept them as input). 
Do I need another implementation, am I completely off with this.
I am very confused and uncertain about this.
Help would be greatly appreciated, Thanks.
 A: What do you mean by solving such integral? Such integral is what it is, i.e. a complete elliptic integral of the second kind. Efficient algorithms for the numerical evaluation are given by the relations between $E,K$ and the AGM mean. If you are fine with algorithms with a linear (instead of a quadratic, or even faster) convergence speed, you may simply exploit the identities
$$\sqrt{1-x}=\sum_{n\geq 0}\frac{1}{4^n}\binom{2n}{n}\frac{x^n}{1-2n} \tag{1} $$
$$ \int_{0}^{\pi/2}\left(\cos\theta\right)^{2n}\,d\theta = \frac{\pi}{2}\cdot\frac{1}{4^n}\binom{2n}{n}\tag{2}$$
leading to
$$ \int_{0}^{\pi/2}\sqrt{1-a^2\cos^2\theta}\,d\theta = \frac{\pi}{2}\sum_{n\geq 0}\left[\frac{1}{4^n}\binom{2n}{n}\right]^2\frac{a^{2n}}{1-2n} \tag{3} $$
where 
$$ \left[\frac{1}{4^n}\binom{2n}{n}\right]^2 \approx \frac{1}{\pi\left(n+\frac{1}{4}\right)}.\tag{4}$$
The complete elliptic integral of the second kind is related to the perimeter of an ellipse, and a very good algebraic approximation is due to Ramanujan, besides weaker inequalities such as 
$$ 2\pi \left(\frac{a^{3/2}+b^{3/2}}{2}\right)^{2/3}\leq  L(a,b)\leq 2\pi\sqrt{\frac{a^2+b^2}{2}}.\tag{5}$$
Other info are contained in the chapter of these notes about elliptic integrals.
A: I found the solution to my problem here:
http://analyticphysics.com/Mathematical%20Methods/A%20Miscellany%20of%20Elliptic%20Integrals.htm
To quote:
$$E(-m)=\sqrt{m+1} E \left (\frac{m}{m+1} \right )$$
Simply building an if clause into my driver to choose $-m$ whenever $m<0$ and then use the formula indicated above gave me the result WolfrAmalpha shows in  wolframalpha.com/input/?i=plot+EllipticE%5Bx%5D.
The discussion here was what got me to ask the right question. Thanks Jack D'Aurizio.
A: When the integrand is the root of 1+a^2 Cos^(x)  one converts it to the elliptic integral by replacing cos^2 by 1-sin^2  to get (1+a^2) - sin^2(x)
Then divide through by (1+a^2)  to get 1/root(1+a^2)  outside the integrand's root sign and 1 -  m.sin^2(x) inside the root sign,  which is the elliptic integral E(m),  where m = 1/(1+a^2).
However if the original integrand is root 1-  a^2.cos^2 ,  and it is the complete integral from 0 to Pi/2 ,  you don't need to do anything to  it, as it is already E(m)  with m=a^2.  The reason is,  in the case of the complete integral,  it does not matter whether it is sin or cos within the square root sign,  as both trace out the same values between 0 and Pi/2 , so the complete integral is the same for both.
That makes me wonder if there was a typo in your question.  Does your original integrand perhaps have a +  sign under the root sign in front of the cos^2 term that prompted you to manipulate it into the form of E(m)?
If,  not,  your original integral is already E(m)  even though most definitions show sin instead of cos.
(I meet this integral often in antenna theory)
