TITLE: True value of $\int_0^{\pi/2}\frac{dx}{(1-2\sin^2 x)\sqrt{1-4\sin^2 x}}$
QUESTION [5 upvotes]: During the generation of test values I stumbled over this question

What is the true value of the complete elliptic integral of the 3rd kind
  $$I=\int_0^{\pi/2}\frac{dx}{(1-2\sin^2 x)\sqrt{1-4\sin^2 x}}?$$

This is a special case of the $\Pi$ integral (see e.g. https://dlmf.nist.gov/19.2.E7) and the Cauchy principal value has to be taken.
Here are my experiments with some well-known resources:
With Wolfram/Mathematica style elliptic integrals (using parameters) the value should be
$$I=\Pi(2|4)=\mathtt{EllipticPi}[2,4] \approx -0.36396057469 - 0.53912891187i$$
With Maple style integrals (using modulus) it should be
$$I=\Pi(2,2)=\mathtt{EllipticPi}(2,2) \approx 1.20683575210 - 0.53912891187 i$$
(Note  that the imaginary parts are the same).
In order to resolve the different results, I asked Wolfram Alpha to evaluate the integral using
int(1/((1-2*sin(x)^2)*sqrt(1-4*sin(x)^2)), x=0..Pi/2) with 30 digits
as input and got the very disturbing different (!?) results
Computation result:    1.05574680871 - 3.53800841627 i 
Decimal approximation: 1.11534422571 + 1.91703566486 i

Pari/GP 2.9.4 gives another numerical integration result
? intnum(x=0,Pi/2,1/((1-2*sin(x)^2)*sqrt(1-4*sin(x)^2)))
%1 = 1.046038054724273208736077496 + 4.797148009326248296 E27*I


Edit (May 2018): I did not expect an answer after two month, therefore I update
the question. Since I am interested in the real part only, I meanwhile use the following formulas:
For $|k|>1, \nu \ne k^2$ the following formula (derived from http://functions.wolfram.com/08.06.04.0029.01 with $x=\pi/2$):
$$
\Re \Pi(\nu,k) = \frac{1}{k}\; \Pi\left(\frac{\nu}{k^2} , \frac{1}{k}\right)
- \Re \left(\frac{\pi}{2} \; \sqrt{\frac{\nu}{(\nu - 1)(k^2 - \nu)}}\;\;\right)
$$
(the second term is zero for $k^2 < \nu$), 
and for $\nu=k^2 > 1$ the result is (c.f. http://functions.wolfram.com/08.03.03.0003.01):
$$
\Pi(k^2,k)\ = \frac{E(k)}{1-k^2}\;\cdot
$$

REPLY [2 votes]: To compute the principal value, we can use contour integration.
Using the substitution $z=e^{ix}$, we have
$$\newcommand{\PV}{\operatorname{PV}}
\begin{align}
\PV\int_0^{\pi/2}\frac{\mathrm{d}x}{\left(1-2\sin^2(x)\right)\sqrt{1-4\sin^2(x)}}
&=\PV\int_0^{\pi/2}\frac{\mathrm{d}x}{\cos(2x)\sqrt{2\cos(2x)-1}}\\
&=\PV\int_0^\pi\frac{\mathrm{d}x}{2\cos(x)\sqrt{2\cos(x)-1}}\\
&=\PV\frac12\int_0^{2\pi}\frac{\mathrm{d}x}{2\cos(x)\sqrt{2\cos(x)-1}}\\
&=\frac1{2i}\oint_\gamma\frac{\mathrm{d}z}{\left(z^2+1\right)\sqrt{z+1/z-1}}\\
&=\frac1{2i}\oint_\gamma\sqrt{\frac{z}{z^2-z+1}}\frac{\mathrm{d}z}{z^2+1}\tag1
\end{align}
$$
where $\gamma$ is the counterclockwise circle of radius $1$ with two infinitesimal green semi-circular detours around the singularities and two infinitesimal red semi-circular detours around the branch cuts $X=e^{\pi i/3}[0,1]\cup e^{-\pi i/3}[1,\infty]$ :

Since the residues at $i$ and $-i$ are negatives, the contributions from the infinitesimal green semi-circles cancel. The integrals along the infinitesimal red semi-circles are bounded by $O\!\left(\sqrt{r}\right)$ as $r\to0$, so those integrals vanish.
$f(z)=\sqrt{\frac{z}{z^2-z+1}}$ is well-defined on $\mathbb{C}\setminus X$ if we set $f(1)=1$. On $|z|=1$, $f(z)\gt0$ for $\operatorname{Re}(z)\gt\frac12$ and $i\,f(z)\gt0$ for $\operatorname{Re}(z)\lt\frac12$.
The contour above can be contracted about the finite part of the branch cut, $e^{\pi i/3}[0,1]$:

On the right side of the branch cut, using the substitution $z=te^{\pi i/3}$ and the formula
$$
\sqrt{a+bi\vphantom{b^2}}=
\sqrt{\frac{a+\sqrt{a^2+b^2}}2}+i\operatorname{sgn}(b)\sqrt{\frac{-a+\sqrt{a^2+b^2}}2}\tag2
$$
we have
$$
\begin{align}
f(z)
&=f\!\left(te^{\pi i/3}\right)\\[9pt]
&=\sqrt{\frac{t}{1-t^3}\left(\frac{1-t}2+i\sqrt3\frac{1+t}2\right)}\\[3pt]
&=\frac12\sqrt{\frac{t}{1-t^3}}\left(\sqrt{1-t+2\sqrt{1+t+t^2}}+i\sqrt{-1+t+2\sqrt{1+t+t^2}}\right)\\[9pt]
&=g(t)\tag3
\end{align}
$$
Notice that $f(z)=g(t)$ is in the first quadrant.
On the left side of the branch cut, $f(z)$ is the negative of that given above. Then $f(z)=-g(t)$ is in the third quadrant.
Furthermore, on the right side of the branch cut
$$
\begin{align}
\frac{\mathrm{d}z}{z^2+1}
&=\frac{e^{\pi i/3}\mathrm{d}t}{t^2e^{2\pi i/3}+1}\\
&=\left(\frac{1+t^2}2+i\sqrt3\frac{1-t^2}2\right)\frac{\mathrm{d}t}{1-t^2+t^4}\\[6pt]
&=h(t)\,\mathrm{d}t\tag4
\end{align}
$$
on the left side of the branch cut, the direction is reversed, so the sign of $h(t)\,\mathrm{d}t$ is negated.
Thus, the integral on both sides of the branch cut is twice the integral on the right side. Therefore,
$$
\begin{align}
\frac1{2i}\oint_\gamma\sqrt{\frac{z}{z^2-z+1}}\frac{\mathrm{d}z}{z^2+1}
&=2\cdot\frac1{2i}\int_0^1g(t)\,h(t)\,\mathrm{d}t\\
&=-i\int_0^1g(t)\,h(t)\,\mathrm{d}t\tag5
\end{align}
$$
Using $(3)$, $(4)$, and $(5)$, we can compute the integral numerically:
$$
1.2068357521005973203335-0.5391289118749108088597i\tag6
$$