<s>[INST] Evaluate $\int \frac{dx}{3\sin(x)+2\cos(x)+3}$ $$\int \frac{1}{3\sin(x)+2\cos(x)+3}\ \text{d}x$$
This is one of the question which appeared in my exam today and I tried solving this but just couldn't solve it.
I tried converting sine and cosine in terms of $\tan\left(\frac{x}{2}\right)$ but didn't help very well..
Does anyone have idea how to evaluate this integral?
 [/INST] Notice, $$\int \frac{1}{3\sin x+2\cos x+3}\ dx$$
$$=\int \frac{1}{3\frac{2\tan\frac{x}{2}}{1+\tan^2\frac{x}{2}}+2\frac{1-\tan^2\frac{x}{2}}{1+\tan^2\frac{x}{2}}+3}\ dx$$
$$=\int \frac{1+\tan^2\frac{x}{2}}{\tan^2\frac{x}{2}+6\tan\frac{x}{2}+5}\ dx$$
$$=\int \frac{\sec^2\frac{x}{2}}{\left(\tan\frac{x}{2}+3\right)^2-4}\ dx$$
Let $\tan\frac{x}{2}=t\implies \frac{1}{2}\sec^2\frac{x}{2}\ dx=dt$
$$=\int \frac{2\ dt}{t^2-4}$$ $$=\frac{2}{4}\ln\left|\frac{t-2}{t+2}\right|+C$$
$$=\color{blue}{\frac{1}{2}\ln\left|\frac{\tan\frac{x}{2}-2}{\tan\frac{x}{2}+2}\right|+C}$$
</s>