Computing $\int_0^\pi \frac{dx}{1+a^2\cos^2(x)}$ 
I am trying to compute the following integral
  $$\int_0^\pi \frac{dx}{1+a^2\cos^2(x)}$$ 

But I got stuck on my way. 
Indeed, enforcing the change of variables $t =\cos^2x$ leads to 
$$\int_0^\pi \frac{d x}{1+a^2\cos^2(x)}= \int_{-1}^1 \frac{d x}{(1+a^2t^2)(1-t^2)^{1/2}}dx =2\int_{0}^1 \frac{d x}{(1+a^2t^2)(1-t^2)^{1/2}}dx$$
then what next? I though this was related the beta and Gamma function but it seems not. Can some help me here?
 A: Bioche's rules say the right substitution should be $t=\tan x$.
Indeed, then $\; \mathrm d x=\dfrac{ \mathrm d t}{1+t^2}$, so that 
\begin{align}\int\frac{\mathrm d x}{1+a^2\cos^2(x)}&=\int\frac{\mathrm d t}{(1+t^2)\biggl(1+\cfrac{a^2}{1+t^2}\biggr)}=\int\frac{\mathrm d t}{1+a^2+t^2}\\&=\frac1{\sqrt{1+a^2}}\,\arctan \frac t{\sqrt{1+a^2}}.
\end{align}
A: Let $u=a\cos x$. Then $du=-a\sin x\,dx$ and $u(0)=a; u(\pi)=-a$ so $$\int_0^\pi \frac{\sin x}{1+a^2\cos^2(x)}dx=-\frac1a\int_{-a}^a\frac1{1+u^2}\,du$$ or $$-\frac1a\left[\tan^{-1}u\right]_{-a}^a=-\frac1a(2\tan^{-1}a)=\boxed{-\frac2a\tan^{-1}a}$$
A: i would use $$\sin(x)=\frac{2t}{1+t^2}$$
$$\cos(x)=\frac{1-t^2}{1+t^2}$$ and $$dx=\frac{2}{1+t^2}dt$$
A: Here is another way. Consider the identity $$\cos^2x=\frac{1+\cos 2x}{2}$$ and the integral is then transformed into $$2\int_{0}^{\pi}\frac{dx}{2+a^2+a^2\cos 2x}$$ and using substitution $$2x=t$$ we get $$\int_{0}^{2\pi}\frac{dt}{2+a^2+a^2\cos t} $$ Since $\cos(2\pi - t) =\cos t$ we can see that the above integral is equal to $$2\int_{0}^{\pi}\frac{dt}{2+a^2+a^2\cos t} $$ and using the standard formula $$\int_{0}^{\pi}\frac{dx}{A+B\cos x}=\frac{\pi} {\sqrt{A^2-B^2}}$$ we can see that the integral in question is equal to $$\frac{2\pi}{\sqrt{(2+a^2)^2-a^4}}=\frac{\pi}{\sqrt{1+a^2}}$$ The standard formula given above can be proved using the substitution $$(A+B\cos x) (A-B\cos y) =A^2-B^2$$ and is valid for $A>|B|$. 
