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$

Hint

Let $y=\dfrac{a\cos x+b\sin x +c}{1+\sin x+\sqrt3\cos x}$

Find $\dfrac{dy}{dx}$

Compare $-(a\cos x+b\sin x+c)(\cos x-\sqrt3\sin x)+(1+\sin x+\sqrt3\cos x)(-a\sin x+b\cos x)$

with $\cos x+\sqrt3$

to find $a,b,c$

For example, by comparing the coefficient of $\cos x\sin x$ we get $b=\sqrt3a$

By $\sin x,a=-\sqrt3c$

So we reach at the expression below with $c$ as constant multiple $$(-\sqrt3\cos x+3\sin x+1)(\cos x-\sqrt3\sin x)+(1+\sin x+\sqrt3\cos x)(\sqrt3\cos x+3\sin x)$$

Can you take it from here?


Let $t=x-\frac\pi6$ to get

\begin{align} & I= \int \frac{\cos x+ \sqrt 3}{1+ 4 \sin(x+\frac{\pi}{3}) + 4\sin^2(x+\frac{\pi}{3})}{d}x =\int \frac{\frac{\sqrt3}2(2+\cos t)-\frac12\sin t }{(1+ 2 \cos t)^2}{d}t \end{align} Note that $\left( \frac{\sin t}{1+2\cos t}\right)’ = \frac{2+\cos t}{(1+2\cos t)^2}$ and $\left( \frac1{1+2\cos t}\right)’ = \frac{2\sin t}{(1+2\cos t)^2}$. Then $$I = \frac{\sqrt3}2 \frac{\sin t}{1+2\cos t}- \frac14\frac{1}{1+2\cos t} = \frac{2\sqrt3\sin t-1}{4(2\cos t+1)}+C $$


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.