<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] $$I=\int \frac{\cos 2x \: dx}{3 \sin x+4 \cos x} = \dfrac15\int \frac{\cos 2x \: dx}{\dfrac35 \sin x+\dfrac45 \cos x} = \dfrac15\int \frac{\cos 2x \: dx}{\cos(x - \alpha)}$$
Where $\alpha = \cos^{-1} \dfrac45$
$$\dfrac15\int \frac{\cos 2x \: dx}{\cos(x - \alpha)} = \dfrac15\int \frac{2\cos^2 x - 1 \: }{\cos(x - \alpha)}\ dx = \dfrac15\int \frac{2\cos^2 x  \: }{\cos(x - \alpha)}\ dx - \dfrac15\int \sec(x - \alpha) dx$$
Now for the first integral, let $u = x - \alpha$
$$\dfrac25\int \frac{\cos^2 (u + \alpha)  }{\cos(u)}\ du = \dfrac25\int \frac{(\cos u \cos \alpha - \sin u \sin \alpha)^2  }{\cos(u)}\ du \\= \dfrac25\int\frac{(\cos^2 u \cos^2 \alpha + \sin^2 u \sin^2 \alpha) + 2\sin \alpha \cos \alpha \sin u \cos u   }{\cos(u)}\ du\\=\dfrac25\int{\cos u \cos^2 \alpha}\ du + \dfrac25\int \frac{\sin^2 u \sin^2 \alpha}{\cos u} du+ \dfrac25\int {2\sin \alpha \cos \alpha \sin u   }{}\ du $$
The middle integral,
$$\dfrac25\int \frac{(1 -\cos^2 u) \sin^2 \alpha}{\cos u}\ du = \dfrac25\int{\sec u \sin^2 \alpha}\ du - \dfrac25\int \cos u \sin^2 \alpha \ du$$
So the answer is,
$$I = \dfrac25\int{\sec u \sin^2 \alpha}\ du - \dfrac25\int \cos u \sin^2 \alpha \ du + \dfrac25\int{\cos u \cos^2 \alpha}\ du + \dfrac25\int {2\sin \alpha \cos \alpha \sin u   }{}\ du -\dfrac15\int \sec(u) du$$ 
$$I = \dfrac25\sin^2 \alpha\int{\sec u }\ du + \dfrac25\cos (2\alpha)\int{\cos u }\ du + \dfrac25\sin (2\alpha)\int { \sin u   }{}\ du -\dfrac15\int \sec(u) du$$ 
</s>