How do you integrate $\int \frac{1}{a + \cos x} dx$? How do you integrate $\int \frac{1}{a + \cos x} dx$?  Is it solvable by elementary methods?  I was trying to do it while incorrectly solving a homework problem but I couldn't find the answer.
Thanks!

This doesn't help you to evaluate the indefinite integral, but I though I would add that the definite integral $\int_0^{2 \pi
} \frac{1}{a + \cos x} \ dx$ can also be evaluated using methods from complex analysis. Let us make the simplifying assumption that $a > 1$  to avoid a blow up in the integral. Other values of $a$ (including complex ones!) can be made to work too. 
We have
\begin{align*}
\int_0^{2 \pi
} \frac{dx}{a + \cos x}  &= \int_0^{2 \pi} \frac{dx}{a + \frac{e^{ix} + e^{-ix}}{2}}  \\
&= 2\int_0^{2 \pi} \frac{e^{ix} \ dx}{2ae^{ix} + e^{2ix} + 1} && \text{Let } z=e^{ix}, \text{ so } dz = ie^{ix} \ dx. \\
&= \frac{2}{i} \int_{|z|=1} \frac{dz}{z^2 + 2az + 1} \\
&= \frac{2}{i} \int_{|z|=1} \frac{dz}{(z-z_1)(z-z_2)}
\end{align*}
where the circle $|z|=1$ is parametrized counterclockwise and
\begin{align*} z_1 = -a - \sqrt{a^2-1}  && z_2 = -a + \sqrt{a^2-1}.
\end{align*}
Clearly $z_1 < -a < -1$, so $z_1$ is outside of the unit circle. As for $z_2$, it is convenient to notice that
\begin{align*}
z_1 z_2 = 1. 
\end{align*}
Thus, since $z_1$ is outside the unit circle, its inverse $z_2$ is inside the unit circle. So, applying the residue theorem, we have
\begin{align*}
\frac{2}{i} \int_{|z|=1} \frac{dz}{(z-z_1)(z-z_2)}
&= \frac{2}{i} \ 2 \pi i \ \mathrm{Res}\left( \frac{1}{(z-z_1)(z-z_2)}, z_2\right) \\
&= 4 \pi \frac{1}{z_2 - z_1} \\
&= 4 \pi \frac{1}{2 \sqrt{a^2 -1}} \\
&= \frac{2 \pi}{\sqrt{a^2-1}}.
\end{align*}
One can check this result against the one obtained from Arybatha's antiderivative, although a bit of care needs to be taken as an improper integral crops up while making the various substitutions. 
\begin{align*}
\int_0^{2 \pi
} \frac{dx}{a + \cos x} 
&= \int_0^\pi \frac{2 \ dy}{a+1 + (a-1) \tan^2(y)} && y= \frac{x}{2}\\
&= \int_0^\infty \frac{ 2 dt}{ a + 1 + (a-1)t^2} +\int_{-\infty}^0 \frac{ 2 dt}{ a + 1 + (a-1)t^2} && t = \tan(y) \\
&= \frac{2}{\sqrt{a^2-1}} \arctan\left( \sqrt{ \frac{a-1}{a+1}} t \right) \big|_0^\infty + \frac{2}{\sqrt{a^2-1}} \arctan\left( \sqrt{ \frac{a-1}{a+1}} t \right) \big|_{-\infty}^0 \\
&= \frac{2 \pi}{\sqrt{a^2-1}}
\end{align*} 
