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?

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|$. 
