Integrating trigonometric function problem $\int \frac{3\sin x+2\cos x}{2\sin x+3\cos x}dx$ \begin{eqnarray*}
\int \frac{3\sin x+2\cos x}{2\sin x+3\cos x}dx &=&  \int \frac{(3\sin x+2\cos x)/\cos x}{(2\sin x+3\cos x)/\cos x}dx\\ \\
&=& \int \frac{3\tan x +2}{2\tan x +3} dx\\
&& u = \tan x \text{ and } du = \sec^2 x \ dx 
\end{eqnarray*}
Am I going in the right direction with this one? It seems like not. 
 A: Since the integrand has the form
$$\frac{a\sin(x) + b\cos(x)}{c\sin(x) + d\cos(x)},$$
if we write it as
$$\frac{P(x)}{Q(x)} = \frac{a\sin(x) + b\cos(x)}{c\sin(x) + d\cos(x)},$$
then we should be able to find constants $A$ and $B$ such that $P(x) \equiv A Q(x) + B Q'(x)$, so that the integral is simply
$$\int A + B\frac{Q'(x)}{Q(x)} \, dx,$$
where the second term $Q'(x)/Q(x)$ contributes $\log\left (Q(x)\right )$ to the integral.
In our case, we have
$$3\sin(x) + 2\cos(x) \equiv A\left ( 2\sin(x) + 3\cos(x) \right ) + B\left ( 2\cos(x) - 3\sin(x) \right ).$$
Equating coefficients of $\sin(x)$ and $\cos(x)$ yields $2A - 3B = 3$ and $3A + 2B = 2$, and thus $A = \frac{12}{13}$ and $B=-\frac{5}{13}$ (you should check this).
Therefore the integral is just
$$\int \frac{3\sin(x)+2\cos(x)}{2\sin(x)+3\cos(x)} \, dx = \frac{12}{13}x - \frac{5}{13}\log \left ( 2\sin(x)+3\cos(x) \right ) + C.$$
A: \begin{eqnarray*}
\int \frac{3\sin x+2\cos x}{2\sin x+3\cos x}dx &=&  \int \frac{(3\sin x+2\cos x)/\cos x}{(2\sin x+3\cos x)/\cos x}dx\\ \\
&=& \int \frac{3\tan x +2}{2\tan x +3} dx\\\\
& = &\int \frac{(3 \tan x + 2)\sec^2x}{(2 \tan x + 3)\sec^2 x}\,dx \\\\
& = & \int \frac{(3 \tan x + 2)\sec^2 x}{(2 \tan x + 3)(1+ \tan^2 x)}\,dx\\\\
\end{eqnarray*}
Now substitute & simplify (or simplify and substitute) with your chosen $u$-substitution. You'll want to employ partial fractions, after substituting.
$u = \tan x \implies du = \sec^2 x\,dx$.
$$\int \frac{(3 u + 2)\,du}{(2u + 3)(1+u^2)} = \int \left(\dfrac{A}{2u + 3} + \frac{Bu + C}{1 + u^2}\right)\,du$$
Solving for the coefficients of $A, B, C$, we get $$A = -\frac{10}{13},\;\;B = \frac 5{13},\;\;C = \dfrac{12}{13}$$
So our integral becomes: $$\int \frac{1}{13}\left(\frac{5u + 12}{1 + u^2}-\dfrac{10}{2u + 3}\right)\,du = \dfrac{1}{13}\left(\frac 52 \int \frac {2u\,du}{1 + u^2} + 12 \int \frac{du}{1 + u^2} - 5\int \dfrac{2\,du}{2u + 3}   \right)$$
Integrating should be straightforward. Since we well be integrating in terms of $u$, once done, don't forget to "back-substitute", replacing $u$ with $\tan x$.
A: Another way:
$$
\frac{3\sin x+2\cos x}{2\sin x+3\cos x} = \overbrace{\frac{12}{13} + \frac5{13}\tan\left( x - \varphi \right)}^{\text{So integrate this function.}} \text{ where }\tan\varphi = \frac 2 3.
$$
I posted a proof of this trigonometric identity (it's not very hard) in response to this question, and maybe one or the other of these two should be marked as a duplicate.
