Principal value of complete elliptic integral of third kind Q: How to evaluate the following integral?
$$
PV\int_k^1\frac{dt}{(x^2-t^2)\sqrt{(t^2-k^2)(1-t^2)}}
$$
where $k<x<1$. For the sake of definiteness we may assume $x=0.8, k=0.5$.
Attempt: The substitution $t^2=k^2\cos^2\theta+\sin^2\theta$ can be used to transform the integral into
$$
{1\over x^2-1}\int_0^{\pi\over2}\frac{d\theta}{\left(1-\frac{1-k^2}{1-x^2}\sin^2\theta\right)\sqrt{1-(1-k^2)\sin^2\theta}}
$$
which can be expressed as the complete elliptic integral of third kind
$$
{1\over x^2-1}\Pi\left(\frac{1-k^2}{1-x^2},\sqrt{1-k^2}\right)
$$
if $$\frac{1-k^2}{1-x^2}<1\iff x^2<k^2$$
in which case there would not be any singularity in the denominator. But in our case this is not true and the integrand is singular at
$$\theta=\arcsin\left(\sqrt{\frac{1-x^2}{1-k^2}}\right)$$
Can someone show me the right contour for this integral and the nuances that come with it?
 A: I do not know the right contour for this integral but there are no general problems to compute it for your values. With 
$$f(k,x) =\int_k^1\frac{dt}{(x^2-t^2)\sqrt{(t^2-k^2)(1-t^2)}}$$
using Maple integration I get $f(0.5, 0.8)=1.78709921080526937$. If you 
use the Maple form of $\Pi$
$$g(k,x) = \frac{1}{x^2-1}\mathtt{EllipticPi}(\frac{1-k^2}{1-x^2}, \sqrt{1-k^2})$$
you get also $g(0.5, 0.8)=1.78709921080526937$
My own special function library use the Bulirsch function cel 
see http://dlmf.nist.gov/19.2#iii
$$ \Pi(\nu,k) = \mathrm{cel}(\sqrt{1-k^2},1-\nu,1,1)$$
with a port of the Algol procedure including the Cauchy principal value handling for $\nu > 1$, from R. Bulirsch, Numerical Calculation of Elliptic Integrals and Elliptic Functions, part III. Numerische Mathematik 13, 305-315, 1969 (available from http://www.digizeitschriften.de/en/dms/toc/?PPN=PPN362160546_0013)
An alternative implementation with the  Carlson form from 
http://dlmf.nist.gov/19.25 (where you find an explicit case for the Cauchy principal value) is
$$\Pi(\nu,k) = R_F(0,{k^{'}}^{2},1) + \frac{\nu}{3} R_J(0,{k^{'}}^{2},1,1-\nu), \quad {k^{'}}^{2}= 1-k^2 $$
Both library versions give $1.78709921080526937\,$ for your example values.
A: Using the parameter notation,
$$PV \int_k^1
 \frac {dt} {(x^2 - t^2) \sqrt {(t^2 - k^2) (1 - t^2)}} =\\
\frac 1 {1 - x^2} \left( \Pi(1 - x^2, 1 - k^2) - K(1 - k^2) \right), \\
0 < k < x < 1.$$
This is independent of how $K$ and $\Pi$ are extended to arguments outside $(0, 1)$. Can be derived in a similar way to this.
