TITLE: How to integrate $\int \frac{\cos(x) + \sqrt 3}{1+ 4 \sin(x+\frac{\pi}{3}) + 4\sin^2(x+\frac{\pi}{3})}{\rm d}x$
QUESTION [5 upvotes]: The question given is to calculate
$$\int \frac{\cos(x) + \sqrt 3}{1+ 4 \sin(x+\frac{\pi}{3}) + 4\sin^2(x+\frac{\pi}{3})}{\rm d}x$$
My attempt
I managed to figure out that the denominator is given out as a perfect square of $$\{1+2\sin(x + \frac{\pi}{3})\}$$ and broke the $\sin(x+\frac{\pi}{3})$ so it looks like
$$\int \frac{\cos(x) + \sqrt 3}{(1+ \sin(x) +\sqrt 3 \cos(x))^2}{\rm d}x$$
I can't figure out how to approach further. Please guide me through this question.

REPLY [3 votes]: Too long for a comment.
Making the problem more general where you have
$$\int \frac{A(x)}{[B(x)]^2}\,dx$$ because of the square in denominator is to guess, as a first attempt, that it could be
$$\int \frac{A(x)}{[B(x)]^2}\,dx=\frac{P(x)}{B(x)}$$ Differentiating both sides gives
$$A(x)=B(x)P'(x)-B'(x)P(x)$$ and try to indentify.
Quite often during your studies, you will face this kind of situations in particular when $A(x)$ and $B(x)$ are polynomials or linear combinations of sines and cosines.
This is exactly what @lab bhattacharjee did in his answer.