<s>[INST] Integration of $\int \frac{dx}{a+f^2(x)}$ I want to solve a integral of the form:
$$
\int \frac{dx}{a+f^2(x)}  
$$
in my particular case I got
$$
\int \frac{dx}{5+\cos^2(x)}
$$
in my case I followed this process:
$$
\int \frac{dx}{5+\cos^2(x)} \\
let \ t = tg(\frac{x}{2}) => 
dx = \frac{2dt}{1+t^2}\\
\int \frac{dx}{5+\cos^2(x)} = \int \frac{\frac{2\,dt}{1+t^2}}{5+(\frac{1-t^2}{1+t^2})^2}\\
$$
Expanding the denominator
$$
5+(\frac{1-t^2}{1+t^2})^2 = \frac{5(1+t^2)^2+(1-t^2)^2}{(1+t^2)^2}
$$
Rewriting all:
$$
\int \frac{2\,dt}{1+t^2} \frac{(1+t^2)^2}{5(1+t^2)^2+(1-t^2)^2} = \\
2 \int \frac{(1+t^2)}{5(1+t^2)^2+(1-t^2)^2}dt
$$
Now I am stuck, I can try to expand the denominator again, but then I cannot divide it for the numerator, something like this:
$$
2 \int \frac{1+t^2}{5(1+2t^2+t^4)+(1-2t^2+t^4)} \,dt = \\
2 \int \frac{1+t^2}{5+10t^2+5t^4+1-2t^2+t^4} \,dt = \\
2 \int \frac{1+t^2}{6t^4+8t^2+6} \,dt = \\
\int \frac{1+t^2}{3t^4+4t^2+3}\, dt
$$
But now I really don't know how to move next...
 [/INST] Let $f$ be the function such that for all real number $x$, $f(x) = \frac{1}{5+\cos^{2}(x)}$. The primitive you want to compute is 
$$ \int f(x) \, dx $$ 
Since $f(x) \, dx$ is invariant under the change of variables $x \rightarrow \pi+x$, the change of variables $t=\tan(x)$ might lead to more simple computations. Let's work with this change of variables. We have : $dt = (1+t^{2})dx$. So,
$$
\begin{align*}
\int \frac{1}{5+\cos^{2}(x)} \, dx &= \int \frac{1}{5 + \frac{1}{t^{2}+1}} \frac{1}{1+t^{2}} \, dt \\
&= \int \frac{1}{5(t^{2}+1)+1} \, dt \\
&= \int \frac{1}{5t^{2}+6} \, dt \\
\end{align*}
$$
And (if I'm not mistaken) :
$$ \int \frac{1}{5t^2+6} \, dt = \frac{1}{\sqrt{30}} \arctan \left( \frac{\sqrt{5}}{\sqrt{6}} t \right)$$
So, the result is :

$$ \int \frac{1}{5+\cos^{2}(x)} \, dx = \frac{1}{\sqrt{30}} \arctan \left( \frac{\sqrt{5}}{\sqrt{6}} \tan(x) \right) $$

</s>