<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] HINT:
$$\int \frac{1}{3\sin(x)+2\cos(x)+3}\text{d}x =$$

Substitute $u=\tan\left(\frac{x}{2}\right)$ and $\text{d}u=\frac{1}{2}\sec^2\left(\frac{x}{2}\right)\text{d}x$. Than transform the integrand using the substitutions $\sin(x)=\frac{2u}{u^2+1}$, $\cos(x)=\frac{1-u^2}{u^2+1}$ and $\text{d}x=\frac{2}{u^2+1}\text{d}u$:

$$\int \frac{2}{(u^2+1)\cdot\left(\frac{6u}{u^2+1}+\frac{2(1-u^2)}{u^2+1}+3\right)}\text{d}u =$$
$$\int \frac{2}{u^2+6u+5}\text{d}u =$$
$$2\int \frac{1}{(u+3)^2-4}\text{d}u=$$

Substitute $s=u+3$ and $\text{d}s=\text{d}u$:

$$2\int \frac{1}{s^2-4}\text{d}s=$$
$$2\int -\frac{1}{4\left(1-\frac{s^2}{4}\right)}\text{d}s=$$
$$-\frac{1}{2}\int \frac{1}{1-\frac{s^2}{4}}\text{d}s=$$

Substitute $p=\frac{s}{2}$ and $\text{d}p=\frac{1}{2}\text{d}s$:

$$-\int \frac{1}{1-p^2}\text{d}p=$$
$$-\tanh^{-1}(p)+C$$
Substitute everything back and you'll get the final answer!
</s>