Integral of $ 1 \, / \, (1 + a \, \cos(x) )$ Let $a<1$ be a positive constant. How can I compute the following integral?
$$
\int_{0}^{2\pi} \frac{1}{1 + a \, \, \cos(x)} dx 
$$
 A: For $|A|\ge 1$, the integral diverges.  For $|A|<1$, we can use the Weierstrass substitution (or alternatively, use contour integration) to evaluate the integral.
Proceeding, we first write
$$\int_0^{2\pi }\frac{1}{1+A\cos(x)}\,dx=2\int_0^{\pi }\frac{1}{1+A\cos(x)}\,dx$$
Then, letting $t=\tan(x/2)$ so that $\cos(x)=\frac{1-t^2}{1+t^2}$ and $dx=\frac{2}{1+t^2}\,dt$, we obtain
$$2\int_0^{\pi }\frac{1}{1+A\cos(x)}\,dx=4\int_0^\infty \frac{1}{(1-A)t^2+1+A}\,dt$$
Can you finish now?
A: An alternative approach. If $0<a<b$, we have
$$ \frac{1}{2}\int_{0}^{2\pi}\frac{d\theta}{(b+a\cos\theta)^2} = \frac{\pi b}{(b^2-a^2)^{3/2}}\tag{1} $$
since the LHS of $(1)$ is the area of an ellipse written in polar coordinates (with the origin at a focus). Integrating both sides of $(1)$ with respect to the $b$ variable,
$$ \int_{0}^{2\pi}\frac{d\theta}{b+a\cos\theta}=\frac{2\pi}{\sqrt{b^2-a^2}}\tag{2}$$
follows. Now it is enough to set $b=1$ to get the answer, $\color{red}{\frac{2\pi}{\sqrt{1-a^2}}} $.
A: $\newcommand{\bbx}[1]{\,\bbox[8px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

I'll assume $\ds{a \in \pars{-1,1}}$:

\begin{align}
\int_{0}^{2\pi}{\dd x \over 1 + a\cos\pars{x}} & =
\int_{0}^{2\pi}{\dd x \over 1 + a\bracks{2\cos^{2}\pars{x/2} - 1}} =
2\int_{0}^{\pi}{\dd x \over 1 - a + 2a\cos^{2}\pars{x}}
\\[5mm] & =
2\int_{-\pi/2}^{\pi/2}{\dd x \over 1 - a + 2a\sin^{2}\pars{x}} =
4\int_{0}^{\pi/2}{\dd x \over 1 - a + 2a\bracks{1 - \cos^{2}\pars{x}}}
\\[5mm] & =
4\int_{0}^{\pi/2}{\sec^{2}\pars{x} \over \pars{1 + a}\sec^{2}\pars{x} - 2a}
\,\dd x =
4\int_{0}^{\pi/2}{\sec^{2}\pars{x} \over \pars{1 + a}\tan^{2}\pars{x} + 1 - a}
\,\dd x
\\[5mm] & \stackrel{t\ =\ \tan\pars{x}}{=}\,\,\,
4\int_{0}^{\infty}{\dd t \over \pars{1 + a}t^{2} + 1 - a}\,\dd x =
\bbx{\ds{2\pi \over \root{1 - a^{2}}}}
\end{align}
