Evaluating the integral with trigonometric integrand While solving another problem I have come across this integral which I am unable to evaluate. Can someone please evaluate the following integral? Thank you. 

$$\int_0^{2\pi}\frac{1}{(2+\cos\theta)^2}\,d\theta.$$

 A: Here's the contour integration approach.
$$\int_{0}^{2 \pi} \frac{1}{(2+ \cos \theta)^{2}} \ d \theta = \int_{0}^{2 \pi} \frac{1}{(2+\frac{e^{i \theta} + e^{- i \theta}}{2})^{2}} \ d \theta$$
Let $z=e^{i \theta}$.
Then
$$  \begin{align}\int_{0}^{2 \pi} \frac{1}{(2+ \cos \theta)^{2}} \ d \theta &= \int_{|z|=1} \frac{1}{(2+\frac{z+z^{-1}}{2})^{2}} \frac{dz}{iz} \\ &= \frac{4}{i}\int_{|z|=1}  \frac{z}{(z^{2}+4z+1)^{2}} \ d z  \\ &=\frac{4}{i} \int_{|z|=1}\frac{z}{[(z-\sqrt{3}+2)(z+\sqrt{3}+2)]^{2}} \ dz \end{align}$$
The only pole inside the unit circle is at $z= \sqrt{3}-2$.
Therefore,
$$ \begin{align} \int_{0}^{2 \pi} \frac{1}{(2+ \cos \theta)^{2}} \ d \theta &= 2 \pi i \frac{4}{i} \text{Res} \left[ \frac{z}{[(z-\sqrt{3}+2)(z+\sqrt{3}+2)]^{2}}, \sqrt{3}-2 \right] \\ &= 8 \pi \lim_{z \to \sqrt{3}-2} \frac{d}{dz} \frac{z}{(z+\sqrt{3}+2)^{2}}
\\ &= 8 \pi \lim_{z \to \sqrt{3}-2} \frac{(z+\sqrt{3}+2)^{2}-2z(z+\sqrt{3}+2)}{(z+\sqrt{3}+2)^{4}} \\ &= 8 \pi \lim_{z \to \sqrt{3}-2} \frac{-z+ \sqrt{3} + 2}{(z+\sqrt{3}+2)^{3}} \\ &= 8 \pi \frac{4}{24 \sqrt{3}} = \frac{4 \pi}{3 \sqrt{3}} \end{align}$$
A: Here is an ugly way of doing it. Pranav's solution is much more elegant.
First substitute $u = \tan(\tfrac{\theta}{2})$ and $\mathrm{d}u = \tfrac{1}{2} \sec^2(\tfrac{\theta}{2})\mathrm{d}\theta$. Then, transform the integrand using the substitution $\sin(\theta) = \frac{2u}{u^2+1}$, $\cos(\theta) = \frac{1-u^2}{u^2+1}$ and $\mathrm{d}\theta = \frac{2\mathrm{d}u}{u^2+1}$ to get $$I = \int \frac{1}{(2+\cos(\theta))^2}\mathrm{d}\theta = \int \frac{2}{(u^2 + 1)\left(\tfrac{1-u^2}{u^2+1} +2\right)^2} \mathrm{d}u = 2\int \frac{u^2+1}{u^4 + 6u^2 +9} \mathrm{d}u.$$
Now, using partial fractions, one can rewrite this integral as
$$I = \frac{2}{3}\int\frac{1}{\tfrac{u^2}{3}+1}\mathrm{d}u - 4\int\frac{1}{(u^2+3)^2}\mathrm{d}u.$$
For the first integrand, substitute $s = \frac{u}{\sqrt{3}}$ and $\mathrm{d}s = \frac{1}{\sqrt{3}}\mathrm{d}u$ to get
$$I = \frac{2}{\sqrt{3}} \int \frac{1}{s^2+1} \mathrm{d}s - 4\int\frac{1}{(u^2+3)^2}\mathrm{d}u.$$ 
We know how to integrate the left side. This is just
$$I = \frac{2\arctan(s)}{\sqrt{3}} - 4\int\frac{1}{(u^2+3)^2}\mathrm{d}u.$$
For the right-hand side, we substitute $u = \sqrt{3}\tan(p)$ and $\mathrm{d}u=\sqrt{3}\sec^2(p)\mathrm{d}p$. Then, we have that $(u^2+3)^2 = (3\tan^2(p) +2)^2 = 9\sec^4(p)$ and $p = \arctan(\tfrac{u}{\sqrt{3}})$. This yields the integral
$$I = \frac{2\arctan(s)}{\sqrt{3}} - \frac{4}{3\sqrt{3}} \int \cos^2(p) \mathrm{d}p.$$
Integrating $\cos^2(p)$ is easy by using the identity $\cos^2(p) = \frac{\cos(2p) + 1}{2}$. All that remains now is to integrate this and substitute your way back to express $I$ in terms of $\theta$. Evaluate from $0$ to $2\pi$ to obtain
$$I_0^{2\pi} = \frac{4\pi}{3\sqrt{3}}.$$
A: HINT :
Using Weierstrass substitution, the integral turns out to be
$$
\int_0^{2\pi}\frac{1}{(2+\cos\theta)^2}\,d\theta=2\int_0^{\pi}\frac{1}{(2+\cos\theta)^2}\,d\theta=4\int_0^\infty\frac{1+x^2}{(3+x^2)^2}\ dt.
$$
Now, using partial fraction decomposition, the integrand turns out to be
$$
\frac{1+x^2}{(3+x^2)^2}=\frac{1}{3+x^2}-\frac{2}{(3+x^2)^2}.
$$
The last step, using substitution $x=\sqrt3\tan t$, the integral should be easy to be evaluated. 
A: Of course you can apply the substitution $t=\tan \frac{\theta}{2}$ directly. 
$$d\theta =\frac{2dt}{1+t^2}$$ and
$$\cos \theta =\frac{1-t^2}{1+t^2}$$
So 
$$2\int_0^{\pi}\frac{d \theta}{(2+\cos\theta)^2}=4\int_0^{\infty} \frac{t^2+1}{(t^2+3)^2}dt$$
A: Google the term "tangent half-angle substitution".
If $u = \tan\dfrac\theta 2$ then $\cos\theta=\dfrac{1-u^2}{1+u^2}$ and $d\theta = \dfrac{2\,du}{1+u^2}$.
As $\theta$ goes from $0$ to $2\pi$, then $u$ goes from $-\infty$ to $\infty$.
If you remember some trigonometry, you can derive what you see above.
\begin{align}
& \int_0^{2\pi}\frac{d\theta}{(2+\cos\theta)^2}
= \int_{-\infty}^\infty \frac{\left(\frac{2\,du}{1+u^2}\right)}{\left(2+\frac{1-u^2}{1+u^2}\right)^2}
= \int_{-\infty}^\infty \frac{2(1+u^2)\,du}{(2(1+u^2)+(1-u^2))^2} \\[10pt]
= {} & \frac 1 2 \int_{-\infty}^\infty \frac{1+u^2}{(3+u^2)^2} \, du
\end{align}
There still a lot of work to do after that.  Use partial fractions.  If your difficulty was in the part that comes after that, this won't help; otherwise maybe it will.
Perhaps this is an argument for using complex variables; residues, etc.: pursuing what you see above is in some ways routine but is onerous.
A: Consider the following integral:
$$I(a)=\int_0^{\pi} \frac{d\theta}{a+\cos\theta}$$
Rewrite $\cos\theta=\frac{1-\tan^2(\theta/2)}{1+\tan^2(\theta/2)}$ to get:
$$I(a)=\int_0^{\pi} \frac{\sec^2(\theta/2)}{a+1+\tan^2(\theta/2)(a-1)}d\theta$$
Use the substitution $\tan(\theta/2)=t \Rightarrow \sec^2(\theta/2)d\theta=2\,dt$ to get:
$$I(a)=\int_0^{\infty} \frac{2}{a+1+(a-1)t^2}\,dt$$
The above is easy to evaluate and gives:
$$I(a)=\frac{\pi}{\sqrt{a^2-1}}$$
Hence,
$$\int_0^{\pi} \frac{d\theta}{a+\cos\theta}=\frac{\pi}{\sqrt{a^2-1}}$$
Differentiate both the sides wrt $a$ to get:
$$\int_0^{\pi} \frac{d\theta}{(a+\cos\theta)^2}=\frac{a\pi}{(a^2-1)^{3/2}}\,\,\,\,\,(*)$$
Getting back to the problem, you have,
$$\int_0^{2\pi}\frac{d\theta}{(2+\cos\theta)^2}=2\int_0^{\pi} \frac{d\theta}{(2+\cos\theta)^2}$$
From $(*)$ and with $a=2$, the final answer is:
$$2\frac{2\pi}{(3\sqrt{3})}=\boxed{\dfrac{4\pi}{3\sqrt{3}}}$$ 
