Calculating $\int \frac{dx}{1+3\sin x+\cos x}$ Can I get a detailed answer on integrating this? I am currently stumped.
$$
 \int \frac{dx}{1+3\sin x+\cos x} 
$$
Thanks.

We can solve this example by taking trigonometric substitution.
Let $$\tan{\frac{x}{2}}=t$$
$$\therefore\frac{1}{2}\sec^{2}{\frac{x}{2}}dx=dt$$
$$\Rightarrow dx=\frac{2dt}{1+t^{2}}$$
Now,
$$\sin x=\frac{2\tan{\frac{x}{2}}}{1+\tan^{2}\frac{x}{2}}=\frac{2t}{1+t^{2}}$$
and
$$\cos x=\frac{1-\tan^{2}\frac{x}{2}}{1+\tan^{2}\frac{x}{2}}=\frac{1-t^{2}}{1+t^{2}}.$$
Therefore our integral becomes,
$$\int \frac{\frac{2dt}{1+t^{2}}}{1+\frac{6t}{1+t^{2}}+\frac{1-t^{2}}{1+t^{2}}}$$
Thus
$$\int \frac{2dt}{1+t^{2}+6t+1-t^{2}}$$
$$\Rightarrow \int\frac{2dt}{2+6t}=\frac{1}{3}\int\frac{dt}{\frac{1}{3}+t}=\frac{1}{3}\log |t+\frac{1}{3}|+C=\frac{1}{3}\log|\tan\frac{x}{2}+\frac{1}{3}|+C.$$
