Evaluating $\int\frac{1}{5\cos x+\sin x+7}~dx$ Evaluating  $$\int\frac{1}{5\cos x+\sin x+7}~dx.$$
This can be done by substituting $$\sin x = \frac{2t}{1 + t^2}$$ and $$\cos x = \frac{1 - t^2}{1 + t^2}.$$
However after I substitute it I cannot simplify it to get anything easier to integrate.
After substituting I got: integral $$\frac{1 + t^2}{2(t + 2)(t + 3)}$$ or $$\frac{1 + t^2}{12 + 2t^2 + 10t}.$$
Could someone give me a hint?
Many thanks.
 A: Use the universal substitution $t=\tan\frac{x}{2}$, we have
$$\sin x=\frac{2t}{1+t^2},\quad \cos x=\frac{1-t^2}{1+t^2},\quad dx=\frac{2}{1+t^2}dt$$
So
$$\frac{1}{5\cos x+\sin x+7}dx=\frac{1}{\frac{5(1-t^2)+2t}{1+t^2}+7}\frac{2dt}{1+t^2}=\frac{2}{2t^2+2t+12}dt=\frac{1}{t^2+t+6}dt=\frac{1}{\left(t+\frac{1}{2}\right)^2+\frac{23}{4}}dt=\frac{4}{23}\cdot\frac{1}{\frac{4}{23}\left(t+\frac{1}{2}\right)^2+1}dt$$
Now recall that 
$$\frac{d}{dt}\arctan(a(t+b))=\frac{a}{a^2(t+b)^2+1}$$
Thus 
$$\frac{d}{dt}\arctan\left(\frac{2}{\sqrt{23}}\left(t+\frac{1}{2}\right)\right)=\frac{2}{\sqrt{23}}\cdot\frac{1}{\frac{4}{23}\left(t+\frac{1}{2}\right)^2+1}$$
It follows that
$$\int \frac{4}{23}\cdot\frac{1}{\frac{4}{23}\left(t+\frac{1}{2}\right)^2+1}dt=\frac{2}{\sqrt{23}}\arctan\left(\frac{2}{\sqrt{23}}\left(t+\frac{1}{2}\right)\right)+C$$
Finally write your answer in terms of $x$:
$$\int\frac{1}{5\cos x+\sin x+7}dx=\frac{2}{\sqrt{23}}\arctan\left(\frac{2}{\sqrt{23}}\left(\tan\frac{x}{2}+\frac{1}{2}\right)\right)+C=\frac{2}{\sqrt{23}}\arctan\left(\frac{1}{\sqrt{23}}\left(2\tan\frac{x}{2}+1\right)\right)+C$$
A: Generally, consider the real function
$$f(x)=\frac{1}{a+b\cos x+c\sin x}$$
With $a^2>b^2+c^2$ so that $f$ is defined on $\mathbb{R}$.
It is not hard to check that the derivative of 
$$F(x)=\frac{x}{d}+\frac{2}{d}\arctan\left(\frac{c\cos x-b\sin x}{d+a+b\cos x+c\sin x}\right)$$
with $d=\sqrt{a^2-b^2-c^2}$, is $f(x)$. So $\int f(x)dx=F(x)+k$. The advantage
of this expression of $F$ is that it is also defined on $\mathbb{R}$. In particular,
$$\int \frac{1}{7+5\cos x+\sin x}=\frac{x}{\sqrt{23}}+\frac{2}{\sqrt{23}}\arctan\left(\frac{\cos x-5\sin x}{\sqrt{23}+7+5\cos x+\sin x}\right)$$
A: Let $t = x - \tan^{-1}\frac15$ to integrate
\begin{align}
& \int\frac{1}{5\cos x+\sin x+7}~dx 
= \int \frac1{\sqrt{26}\cos t +7}dt\\
=& \int \frac{2d(\tan\frac t2)}{(7+\sqrt{26})+(7-\sqrt{26})\tan^2\frac t2}\\
=& \frac2{\sqrt{23}}\tan^{-1} \left( \sqrt{\frac{ 7-\sqrt{26}}{7+\sqrt{26}}}\tan\frac t2 \right)+C
\end{align}
