How can I solve $f(x) = \int \frac{\cos{x}(1+4\cos{2x})}{\sin{x}(1+4\cos^2{x})}dx$? $$f(x) = \int \frac{\cos{x}(1+4\cos{2x})}{\sin{x}(1+4\cos^2{x})}dx$$
I have been up on this problem for an hour, but without any clues. 
Can someone please help me solving this?
 A: It is quite straight forward after rewriting the integrand:
$$\frac{\cos x (1+4\cos 2x )}{\sin x (1+4\cos^2 x)}= \frac{\cos x}{\sin x}\left(1 - \frac{4\sin^2 x}{1+4\cos^2 x}\right)$$
$$= \frac{\cos x}{\sin x} - \frac{2\sin 2x}{3+2\cos 2x}$$
Note, that $(3+2\cos 2x)' = -4\sin 2x$ and integrate:
$$\int \frac{\cos{x}(1+4\cos{2x})}{\sin{x}(1+4\cos^2{x})}dx =\log |\sin x| + \frac 12 \log(3+2\cos 2x) + C$$
A: The integral is $$ \int \frac{\cos x(5-8\sin^2x)}{\sin x(5-4\sin^2x)} dx$$
Substitute $t=\sin x \implies dt =\cos x dx$ to get $$\int \frac{5-8t^2}{t(5-4t^2)} dt$$ Now, use partial fraction decomposition: $$ =\int\frac 1t dt+\int\frac{4t}{4t^2-5}dt $$ Substitute $u=4t^2-5 \implies du=8tdt$ in the second integral:
$$= \ln|t| + \frac 12 \int \frac{du}{u} \\ =\ln|\sin x| +\frac 12 \ln|4\sin^2-5| +C$$
A: Let $x=\tan^{-1}(y)$
$$I= \int \frac{\cos{(x)}(1+4\cos{(2x)})}{\sin{(x)}(1+4\cos^2{(x)})}\,dx=\int \frac{5-3 y^2}{y^5+6 y^3+5 y}\,dy$$ Now, partial fraction decomposition
$$\frac{5-3 y^2}{y^5+6 y^3+5 y}=\frac{1}{y}-\frac{2 y}{y^2+1}+\frac{y}{y^2+5}$$
