How do I integrate $\frac{\sqrt{1-k^2\sin^2 x}}{\sin x}$ How do I evaluate this indefinite integral, for $|k| < 1$:
$$
\int\frac{\sqrt{1-k^2\sin^2 x}}{\sin x}\mathrm{d}x
$$
I tried the change of variable $t=\sin x$, and obtained two integrals, but I can't integrate either. 
 A: Let $u=k\sin x$, so $du=k\cos x dx$.  Then 
$\displaystyle\int \frac{\sqrt{1-k^2\sin^2 x}}{\sin x} dx=k\int\frac{\sqrt{1-u^2}}{u}\cdot\frac{1}{\sqrt{k^2-u^2}}du=k\int\sqrt{\frac{1-u^2}{k^2-u^2}}\cdot\frac{1}{u}du$.
Now let $z=\sqrt{\frac{1-u^2}{k^2-u^2}}$, so $u^2=\frac{1-k^2z^2}{1-z^2}$ and $2udu=\frac{2z(1-k^2)}{(1-z^2)^2}dz$.
Then $\displaystyle\int k\sqrt{\frac{1-u^2}{k^2-u^2}}\cdot\frac{1}{u}du=k\int z\frac{1-z^2}{1-k^2z^2}\frac{z(1-k^2)}{(1-z^2)^2}dz=k(1-k^2)\int\frac{z^2}{(1-z^2)(1-k^2z^2)}dz.$
Then $\frac{z^2}{(1-z^2)(1-k^2z^2)}=\frac{A}{1-z}+\frac{B}{1+z}+\frac{C}{1-kz}+\frac{D}{1+kz}\implies A=B=\frac{-1}{2(k^2-1)}\text{ and } C=D=\frac{1}{2(k^2-1)},$
so $\displaystyle\frac{k}{2}\int\left(\frac{1}{1-z}+\frac{1}{1+z}-\frac{1}{1-kz}-\frac{1}{1+kz}\right) dz$
$=\displaystyle\frac{k}{2}\left[\ln\left\vert\frac{1+z}{1-z}\right\vert-\frac{1}{k}\ln\left\vert\frac{1+kz}{1-kz}\right\vert\right]+C=k\tanh^{-1}t-\tanh^{-1}\frac{t}{k}+C,$  where $\displaystyle z=\sqrt{\frac{1-k^2\sin^{2}x}{k^2-k^2\sin^{2}x}}=\frac{\sqrt{1-k^2\sin^{2}x}}{k\cos x}$ for $k>0$ and $\cos x>0$
and $\displaystyle t=\frac{1}{z}=\frac{k\cos x}{\sqrt{1-k^2\sin^{2}x}}$.
A: Maple says:
$$
\int \!{\frac {\sqrt {1-{k}^{2}  \sin^2 \left( x \right) 
 }}{\sin \left( x \right) }}{dx}
= \frac{1}{2}\left[k\ln  \left( 2 \right) +k
\ln  \left( k \right) -k\ln  \left( -2\, \cos^2 \left( x \right) 
 {k}^{2}+2\,\cos \left( x \right)k \sqrt { \cos^2
 \left( x \right){k}^{2}-{k}^{2}+1}+{k}^{2}-1 \right) -
{\rm atanh} \left({\frac { \cos^2 \left( x \right) 
 {k}^{2}+ \cos^2 \left( x \right)-{k}^{
2}+1}{2\cos \left( x \right) \sqrt {  \cos^2 \left( x \right) 
 {k}^{2}-{k}^{2}+1}}} \right) \right]
$$
A: The following solution is based on a suggestion of lab bhattacharjee:
$\displaystyle\int \frac{\sqrt{1-k^2\sin^2 x}}{\sin x} dx=\int\frac{\sqrt{1-k^2\sin^2 x}}{\sin^{2} x}\cdot\sin x dx=\int\frac{\sqrt{1-k^2(1-\cos^{2}x)}}{1-\cos^{2}x}\cdot\sin x dx$.
Now let $t=\cos x$, $dt=-\sin x dx$ to get $\displaystyle -\int\frac{\sqrt{1-k^2+k^2t^2}}{1-t^2}dt$; then let $kt=\sqrt{1-k^2}\tan\theta$ to get
$\displaystyle-\int\frac{\sqrt{1-k^2}\sec\theta}{1-\frac{1-k^2}{k^2}\tan^{2}\theta}\cdot\frac{\sqrt{1-k^2}}{k}\sec^{2}\theta d\theta=k(k^2-1)\int\frac{\sec^{3}\theta}{k^2\sec^{2}\theta-\tan^{2}\theta}d\theta$
$=\displaystyle k(k^2-1)\int\frac{\sec\theta}{k^2-\sin^{2}\theta}d\theta=k(k^2-1)\int\frac{\cos\theta}{\cos^{2}\theta(k-\sin\theta)(k+\sin\theta)} d\theta$.
Now let $u=\sin\theta$, $du=\cos\theta d\theta$ and use $\cos^{2}\theta=1-\sin^{2}\theta$ to obtain
$\displaystyle k(k^2-1)\int\frac{1}{(1-u)(1+u)(k-u)(k+u)}du$.
Then $\frac{1}{(1-u)(1+u)(k-u)(k+u)}=\frac{A}{1-u}+\frac{B}{1+u}+\frac{C}{k-u}+\frac{D}{k+u}\Rightarrow A=B=\frac{1}{2(k^2-1)} \text{ and }C=D=\frac{-1}{2k(k^2-1)},$
so $\displaystyle \frac{k}{2}\int\left(\frac{1}{1-u}+\frac{1}{1+u}-\frac{1/k}{k-u}-\frac{1/k}{k+u}\right) du=\frac{k}{2}\left[\ln\left\vert\frac{1+u}{1-u}\right\vert-\frac{1}{k}\ln\left\vert\frac{k+u}{k-u}\right\vert\right]+C$
where $\displaystyle u=\sin\theta=\frac{kt}{\sqrt{ k^{2}t^{2}+1-k^2}}=\frac{k\cos x}{\sqrt{ k^2\cos^{2}x+1-k^2}}=\frac{k\cos x}{\sqrt{1-k^2\sin^{2}x}}$.
