Evaluation of $\int\limits_{0}^{2\pi}\frac{a\cos x -1}{(a^2+1-2a\cos x)^{3/2}}dx.$ $$\int\limits_{0}^{2\pi}\frac{a \cos x -1}{(a^2+1-2a \cos x)^{3/2}}dx
= 2\int\limits_{0}^{\pi}\frac{a \cos x -1}{(a^2+1-2a\cos x)^{3/2}}dx.$$
If a<1, this integral doesn't converge. How to evaluate it for any other a? I think it can be expressed as elliptic integral $I(a^2)$ or calculated using series, but stuck using both ways.
 A: Note that $$I\left(a\right)=2\int_{0}^{\pi}\frac{a\cos\left(x\right)-1}{\left(a^{2}+1-2a\cos\left(x\right)\right)^{3/2}}dx
 $$ $$=\frac{d}{da}\left(-2a\int_{0}^{\pi}\frac{1}{\sqrt{a^{2}+1-2a\cos\left(x\right)}}dx\right)
 $$ and, since $a>1$, $$\int_{0}^{\pi}\frac{1}{\sqrt{\left(a+1\right)^{2}-2a-2a\cos\left(x\right)}}dx=\int_{0}^{\pi}\frac{1}{\sqrt{\left(a+1\right)^{2}-2a\left(1+\cos\left(x\right)\right)}}dx
 $$ $$\stackrel{x=2u}{=}\int_{0}^{\pi/2}\frac{1}{\sqrt{\left(a+1\right)^{2}-2a\left(1+\cos\left(2u\right)\right)}}du=\frac{2}{a+1}\int_{0}^{\pi/2}\frac{1}{\sqrt{1-\frac{4a}{\left(a+1\right)^{2}}\cos^{2}\left(u\right)}}du$$ $$\stackrel{u\rightarrow\pi/2-u}{=}\frac{2}{a+1}\int_{0}^{\pi/2}\frac{1}{\sqrt{1-\frac{4a}{\left(a+1\right)^{2}}\sin^{2}\left(u\right)}}du
 =\frac{2}{a+1}K\left(\frac{4a}{\left(a+1\right)^{2}}\right)$$ where $K(z)$ is the complete elliptic integral of the first kind. Hence we have $$I\left(a\right)=\frac{d}{da}\left(\frac{-4a}{a+1}K\left(\frac{4a}{\left(a+1\right)^{2}}\right)\right)=\color{red}{\frac{2\left((a+1)E\left(\frac{4a}{\left(a+1\right)^{2}}\right)-\left(a-1\right)K\left(\frac{4a}{\left(a+1\right)^{2}}\right)\right)}{a^{2}-1}}$$ for $a>1,$ where $E(z)$ is complete elliptic integral of the second kind.
