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$ 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.
 A: 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?
A: 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
$$
A: 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.
A: The denominator of $1+e\cos\theta$ occurs in inverse $r^2$ force problems and when $e\gt1$ as here, corresponds to a hyperbolic orbit, like Rutherford scattering or ʻOumuamua. We can zap this denominator depending on whether the orbit is elliptical, parabolic, or hyperbolic. In the latter case we may let
$$\sin y=\frac{\sqrt{e^2-1}\sinh\theta}{e\cosh\theta-1}=\frac{\sqrt3\sinh\theta}{2\cosh\theta-1}$$
$$\cos y=\frac{e-\cosh\theta}{e\cosh\theta-1}=\frac{2-\cosh\theta}{2\cosh\theta-1}$$
The reader may check that $\cos^2y+\sin^2y=1$. Taking differentials we have
$$\cos y\,dy=\frac{e-\cosh\theta}{e\cosh\theta-1}dy=\frac{\sqrt{e^2-1}(e-\cosh\theta)}{(e\cosh\theta-1)^2}$$
So
$$dy=\frac{\sqrt{e^2-1}}{e\cosh\theta-1}d\theta=\frac{\sqrt3}{2\cosh\theta-1}d\theta$$
And then
$$1+e\cos y=1+2\cos y=\frac{e^2-1}{e\cosh\theta-1}=\frac3{2\cosh\theta-1}$$
$$\cosh\theta=\frac{\cos y+e}{1+e\cos y}=\frac{\cos y+2}{1+2\cos y}$$
$$\sinh\theta=\frac{\sqrt{e^2-1}\sin y}{1+e\cos y}=\frac{\sqrt3\sin y}{1+2\cos y}$$
So we can just clean up the denominator a little by letting $x=y+\frac{\pi}6$ so that $\sin\left(x+\frac{\pi}3\right)=\sin\left(y+\frac{\pi}2\right)=\cos y$ and $\cos x=\cos\left(y+\frac{\pi}6\right)=\frac{\sqrt3}2\cos y-\frac12\sin y$ so we have
$$\begin{align}I&=\int\frac{\cos x+\sqrt3}{\left(1+2\sin\left(x+\frac{\pi}3\right)\right)^2}dy=\int\frac{\frac{\sqrt3}2\cos y-\frac12\sin y+\sqrt3}{(1+2\cos y)^2}dy\\
&=\int\frac{(2\cosh\theta-1)^2}9\left[\frac{\sqrt3}2\frac{(2-\cosh\theta)}{(2\cosh\theta-1)}-\right.\\
&\quad\left.\frac{\sqrt3}2\frac{\sinh\theta}{(2\cosh\theta-1)}+\sqrt3\frac{(2\cosh\theta-1)}{(2\cosh\theta-1)}\right]\frac{\sqrt3\,d\theta}{(2\cosh\theta-1)}\\
&=\int\left(\frac12\cosh\theta-\frac16\sinh\theta\right)d\theta=\frac12\sinh\theta-\frac16\cosh\theta+C_1\\
&=\frac{\frac{\sqrt3}2\sin y-\frac16\cos y-\frac13}{1+2\cos y}+C_1=\frac{\frac{\sqrt3}2\sin y-\frac14}{1+2\cos y}+C\\
&=\frac{\frac34\sin x-\frac{\sqrt3}4\cos x-\frac14}{1+2\cos\left(x-\frac{\pi}6\right)}+C=\frac{\frac34\sin x-\frac{\sqrt3}4\cos x-\frac14}{1+2\sin\left(x+\frac{\pi}3\right)}+C\end{align}$$
