Find $ \int \frac{1}{2\sin(x)-3\cos(x)}dx$. 
Find $\displaystyle \int \dfrac{1}{2\sin(x)-3\cos(x)}dx$.

My book said to solve this by saying $u = \tan \left(\dfrac{x}{2} \right)$ since $\cos(x) = \dfrac{1-u^2}{1+u^2}$ and $\sin(x) = \dfrac{2u}{1+u^2}$. I don't see how this will help since $du = \dfrac{1}{\cos(x)+1}dx $. How will we get that in the integrand?
 A: Hint: (alternative way)
You can write the expression $2\sin(x)-3\cos(x)$ as $\sqrt{13}\sin\left(x-\tan^{-1}\left(\tfrac32\right)\right)$. You'll thus have to integrate: $$\dfrac{1}{\sqrt{13}}\csc\left(x-\tan^{-1}\left(\tfrac32\right)\right).$$
A: Notice, $$\int \frac{1}{2\sin x-3\cos x}\ dx$$
$$=\int \frac{1}{2\frac{2\tan\frac{x}{2}}{1+\tan^2\frac{x}{2}}-3\frac{1-\tan^2\frac{x}{2}}{1+\tan^2\frac{x}{2}}}\ dx$$
$$=\int \frac{1+\tan^2\frac{x}{2}}{3\tan^2\frac{x}{2}+4\tan\frac{x}{2}-3}\ dx$$
$$=\frac13\int \frac{\sec^2\frac{x}{2}}{\tan^2\frac{x}{2}+\frac{4}{3}\tan\frac{x}{2}-1}\ dx$$
$$=\frac23\int \frac{d\left(\tan\frac{x}{2}\right)}{\left(\tan\frac{x}{2}+\frac23\right)^2-\left(\frac{\sqrt{13}}{3}\right)^2}\ dx$$
$$=\frac{2}{3\times 2\frac{\sqrt {13}}{3}}\ln\left|\frac{\tan\frac{x}{2}+\frac23-\frac{\sqrt{13}}{3}}{\tan\frac{x}{2}+\frac23+\frac{\sqrt{13}}{3}}\right|+C$$
$$=\frac{1}{\sqrt {13}}\ln\left|\frac{3\tan\frac{x}{2}+2-\sqrt{13}}{3\tan\frac{x}{2}+2+\sqrt{13}}\right|+C$$
A: Hint:
the suggested substitution works well because:
$$
\cos x+1=\frac{1-u^2}{1+u^2}+1=\frac{2}{1+u^2}
$$
so:
$$
du=\frac{1}{2\cos^2(x/2)}dx= \frac{dx}{\cos x+1} \Rightarrow dx=\frac{2\,du}{1+u^2}
$$
the integral becomes:
$$
2\int\frac{du}{3u^2+4u-3} 
$$
that, completing the square, becomes:
$$
2\int\frac{du}{(\sqrt{3}u+2\sqrt{3}/3)^2-13/3} 
$$
that can be solved with the substitution $t=\sqrt{3}u+2\sqrt{3}/3$ and factorizing $13/3$.
A: The substitution works because you get
$$
x=2\arctan u
$$
so
$$
dx=\frac{2}{1+u^2}\,du
$$
Since
$$
2\sin x-3\cos x=2\frac{2u}{1+u^2}-3\frac{1-u^2}{1+u^2}=
\frac{3u^2- 4u -3}{1+u^2}
$$
the integral becomes
$$
\int\frac{1+u^2}{3u^2- 4u -3}\frac{2}{1+u^2}\,du=
2\int\frac{1}{3u^2-4u  -3}\,du
$$
that's solvable by partial fractions.
A different way is to write
$$
2\sin x-3\cos x=A\sin(x-\varphi)
$$
that becomes
$$
2\sin x-3\cos x=A\sin x\cos\varphi-A\cos x\sin\varphi
$$
so we can set
$$
A\cos\varphi=2,\quad A\sin\varphi=3
$$
and so $A^2=13$. There is a unique angle $\varphi\in[0,2\pi)$ such that
$$
\sin\varphi=\frac{3}{\sqrt{13}},\quad
\cos\varphi=\frac{2}{\sqrt{13}}
$$
Now the integral becomes
$$
\sqrt{13}\int\frac{1}{\sin(x-\varphi)}\,dx
$$
and we can do the substitution $x-\varphi=2u$, so $dx=2\,du$ and the integral is
\begin{align}
\sqrt{13}\int\frac{1}{\sin u\cos u}\,du
&=\sqrt{13}\int\frac{\sin^2u+\cos^2u}{\sin u\cos u}\,du\\
&=\sqrt{13}\left(\int\frac{\sin u}{\cos u}\,du
+\int\frac{\cos u}{\sin u}\,du\right)\\
&=\sqrt{13}(\log|\cos u|-\log|\sin u|)+c
\end{align}
and it's just tedious to do the back substitution.
