<s>[INST] 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?
 [/INST] 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}$$
</s>