<s>[INST] Evaluate $\int \frac{\cos 2x \: dx}{3 \sin x+4 \cos x}$ Evaluate 

$$I=\int \frac{\cos 2x \: dx}{3 \sin x+4 \cos x}$$

My Try:
$$I=\int \frac{(\cos x-\sin x)(\cos x+\sin x)dx}{3 \sin x+4 \cos x}$$
we have $$\cos x-\sin x=\frac{1}{25}(3 \sin x+4 \cos x)+\frac{7}{25}(3 \cos x-4 \sin x)$$  and
$$\cos x+\sin x=\frac{7}{25}(3 \sin x+4 \cos x)+\frac{-1}{25}(3 \cos x-4 \sin x)$$
So
$$\cos 2x=\frac{7}{625}(3 \sin x+4 \cos x)^2+\frac{48}{625}\left((3 \sin x+4 \cos x)(3\cos x-4 \sin x)\right)-\frac{7}{625}(3 \cos x-4 \sin x)^2$$
So
$$I=\frac{7}{625}\int (3 \sin x+4 \cos x)dx+\frac{48}{625}\int (3 \cos x-4 \sin x)dx-J$$
where 
$$J=\frac{7}{625}\int \frac{(3 \cos x-4 \sin x)^2dx}{3 \sin x+4 \cos x}$$
I got stuck up to integrate $J$. 
 [/INST] \begin{align}
Hint:(3\cos x-4\sin x)^2&=25-(3\sin x+4\cos x)^2\\
\int\frac{(3\cos x-4\sin x)^2}{3\sin x+4\cos x}dx&=\int\frac{25-(3\sin x+4\cos x)^2}{3\sin x+4\cos x}dx\\
&=25\int\frac{dx}{3\sin x+4\cos x}-\int(3\sin x+4\cos x)dx\\
&=25\int\frac{dx}{3\sin x-4+4(1+\cos x)}+3\cos x-4\sin x\\
&=25\int\frac{\frac{1}{1+\cos x}dx}{3\frac{\sin x}{1+\cos x}-4\frac{1}{1+\cos x}+4}+3\cos x-4\sin x\\
&=25\int\frac{d(\frac{\sin x}{1+\cos x})}{3\frac{\sin x}{1+\cos x}-2((\frac{\sin x}{1+\cos x})^2+1)+4}+3\cos x-4\sin x\\
&=25\int\frac{dt}{2+3t-2t^2}+3\cos x-4\sin x\\
&=25(\frac{1}{5}\ln \left|\frac{2t+1}{2-t}\right |)+3\cos x-4\sin x\\
&=5\ln \left|\frac{2\sin x+1+\cos x}{2(1+\cos x)-\sin x}\right |+3\cos x-4\sin x+C\\
\end{align}
</s>