integrate simple function I a multiple answer math question and i have solved the problem, the answer exists, but it's not the right one.
$$I =\int \:\frac{1}{a+\cos \left(x\right)}dx$$
Using the substitution $\tan(\frac{x}{2}) = u$ , I got
$$I_1=\int \:\frac{\frac{2}{1+u^2}}{\frac{a\left(1+u^2\right)+\left(1+u^2\right)}{1+u^2}}du=2\int \:\frac{du}{a\left(1+u^2\right)+\left(1-u^2\right)}=\frac{2}{a-1}\int \:\frac{du}{u^2+\sqrt{\frac{a+1}{a-1}}^2}\: => I=\frac{2}{\sqrt{a^2-1}}\arctan \left(\frac{\tan \left(\frac{x}{2}\right)}{\sqrt{\frac{a+1}{a-1}}}\right)+C$$
The correct answer is: $\frac{1}{\sqrt{a^2-1}}\left(x-2\arctan \left(\frac{\sin \left(x\right)}{a+\sqrt{a^2-1}+\cos \left(x\right)}\right)\right)$
Am I missing something ? I really can't tell.
 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}$
\begin{align}
\int{\dd \theta \over a + \cos\pars{\theta}} & =
\int{\dd \theta \over a + \bracks{2\cos^{2}\pars{\theta/2} - 1}} =
\int{\sec^{2}\pars{\theta/2} \over \pars{a - 1}\sec^{2}\pars{\theta/2} + 2}
\,\dd \theta
\\[5mm] & =
\int{\sec^{2}\pars{\theta/2} \over \pars{a - 1}\tan^{2}\pars{\theta/2} + a + 1}
\,\dd \theta
\\[5mm] & =
{1 \over a + 1}\int{\sec^{2}\pars{\theta/2} \over
\bracks{\pars{a - 1}/\pars{a + 1}}\tan^{2}\pars{\theta/2} + 1}
\,\dd \theta
\end{align}

With $\ds{t \equiv \root{a - 1 \over a + 1}\tan\pars{\theta \over 2}\quad}$ and
  $\quad\left\{\begin{array}{rcl}
\ds{\theta} & \ds{=} &
\ds{2\arctan\pars{\root{a + 1 \over a - 1}\,t}}
\\[2mm]
\ds{\quad\sec^{2}\pars{\theta \over 2}\,\dd\theta} & \ds{=} &
\ds{2\root{a + 1 \over a - 1}\dd t}
\end{array}\right.
$:

\begin{align}
\int{\dd \theta \over a + \cos\pars{\theta}} & =
{1 \over a + 1}\bracks{2\root{a + 1 \over a - 1}}\int{\dd t \over t^{2} + 1}
=
{2 \over \root{a^{2} - 1}}\,\arctan\pars{t}
\\[5mm] & =
\bbx{\ds{{2 \over \root{a^{2} - 1}}\arctan\pars{\root{a - 1 \over a + 1}
\tan\pars{\theta \over 2}} + \pars{~\mbox{a constant}~}}}
\end{align}
