Find value of integral: $I=\int_0^{2\pi}\frac{dx}{(2+\cos x)^2}$ Find value of integral: $$I_1=\int_0^{2\pi}\frac{dx}{(2+\cos x)^2}$$ and  $$I_2=\int_0^{2\pi}\frac{dx}{(2+\sin x)^2}$$
I don't know how, i need a solution, please
 A: We can also use contour integration.
Let $z=e^{ix}$, then $\mathrm{d}x=-i\,\mathrm{d}z/z$ and $\cos(x)=\frac{z+1/z}{2}$
$$
\begin{align}
\int_0^{2\pi}\frac{\mathrm{d}x}{(2+\cos(x))^2}
&=\oint\frac{-i\,\mathrm{d}{z}/z}{\left(2+\frac{z+1/z}{2}\right)^2}\\
&=\oint\frac{-4iz\,\mathrm{d}{z}}{(z^2+4z+1)^2}\tag{1}
\end{align}
$$
The zeros of $z^2+4z+1$ are $-2\pm\sqrt3$. $-2-\sqrt3$ is outside the unit circle, so the only pole that matters is at $-2+\sqrt3$.
Partial fractions gives
$$
\frac{z}{(z-a)^2(z-b)^2}=\frac{\frac{a+b}{(b-a)^3}}{z-a}+\frac{\frac{b+a}{(a-b)^3}}{z-b}+\frac{\frac{a}{(a-b)^2}}{(z-a)^2}+\frac{\frac{b}{(b-a)^2}}{(z-b)^2}\tag{2}
$$
With $a=-2+\sqrt3$ and $b=-2-\sqrt3$, we get the residue of $(2)$ at $z=a$ to be $\frac1{6\sqrt3}$. Plugging this into $(1)$ gives
$$
\begin{align}
\int_0^{2\pi}\frac{\mathrm{d}x}{(2+\cos(x))^2}
&=(2\pi i)(-4i)\frac1{6\sqrt3}\\
&=\frac{4\pi}{3\sqrt3}\tag{3}
\end{align}
$$

My original inclination was to use Igor's substitution, just to verify the previous answer, I will compute using the substitution $z=\tan(x/2)$, where $\mathrm{d}x=\frac{2\,\mathrm{d}z}{1+z^2}$ and $\cos(x)=\frac{1-z^2}{1+z^2}$ :
$$
\begin{align}
&\int_0^{2\pi}\frac{\mathrm{d}x}{(2+\cos(x))^2}\\
&=\int_{-\infty}^\infty\frac{\frac{2\,\mathrm{d}z}{1+z^2}}{\left(2+\frac{1-z^2}{1+z^2}\right)^2}\\
&=\int_{-\infty}^\infty\frac{2(1+z^2)\,\mathrm{d}z}{\left(3+z^2\right)^2}\\
&=\int_{-\infty}^\infty\frac{2\,\mathrm{d}z}{3+z^2}-\int_{-\infty}^\infty\frac{4\,\mathrm{d}z}{\left(3+z^2\right)^2}\\
&=\frac2{\sqrt3}\left[\tan^{-1}\left(\frac{z}{\sqrt3}\right)\right]_{-\infty}^\infty-\frac2{3\sqrt3}\left[\tan^{-1}\left(\frac{z}{\sqrt3}\right)+\frac{\sqrt3z}{3+z^2}\right]_{-\infty}^\infty\\
&=\frac{4\pi}{3\sqrt3}\tag{4}
\end{align}
$$
A: Use the $u = \tan x/2$ substitution, which transforms this into a rational function.
A: Let $\displaystyle I = \frac{\sin x}{(2+\cos x)}$
Now Diff. both side w.r. to $x$ , $\displaystyle \frac{dI}{dx} = \frac{d}{dx}\left(\frac{\sin x}{2+\cos x}\right) = \frac{(2+\cos x)\cdot \cos x-\sin x\cdot (-\sin x)}{(2+\cos x)^2}$
$\displaystyle \frac{dI}{dx} = \frac{2\cos x+1}{(2+\cos x)^2}\Rightarrow \frac{dI}{dx} =  \frac{2\cdot \left(2+\cos x\right)-3}{(2+\cos x)^2} = \frac{2}{2+\cos x}-3\cdot \frac{1}{(2+\cos x)^2}$
Now Integrate both side w. r. to $x$
$\displaystyle \int \frac{dI}{dx}dx = 2\int\frac{1}{(2+\cos x)}dx - 3\int\frac{1}{(2+\cos x)^2}dx$
So $\displaystyle \int\frac{1}{(2+\cos x)^2}dx = \frac{2}{3}\int\frac{1}{(2+\cos x)}dx-\frac{1}{3}\cdot I$
Now Put $\displaystyle \cos x = \frac{1-\tan^2 \frac{x}{2}}{1+\tan^2 \frac{x}{2}}$
$\displaystyle \int\frac{1}{(2+\cos x)^2}dx = \frac{2}{3}\int\frac{1+\tan^2 \frac{x}{2}}{2+2\tan^2 \frac{x}{2}+1-\tan^2 \frac{x}{2}}dx-\frac{1}{3}\cdot \frac{\sin x}{2+\cos x}+\mathbb{C}$
$\displaystyle = \frac{2}{3}\int\frac{\sec^2 \frac{x}{2}}{3+\tan^2 \frac{x}{2}}dx-\frac{1}{3}\cdot \frac{\sin x}{2+\cos x}+\mathbb{C}$
Let $\displaystyle \tan \frac{x}{2} = t$ and $\sec^2\frac{x}{2}dx = 2dt$
$\displaystyle = \frac{4}{3}\int \frac{1}{t^2+\left(\sqrt{3}\right)^2}dt-\frac{1}{3}\cdot \frac{\sin x}{2+\cos x}+\mathbb{C}$
$\displaystyle \int\frac{1}{(2+\cos x)^2}dx = \frac{4}{3}\cdot \frac{1}{\sqrt{3}}\cdot \tan^{-1}\left(\frac{\tan \frac{x}{2}}{\sqrt{3}}\right)-\frac{1}{3}\cdot \frac{\sin x}{2+\cos x}+\mathbb{C}$
Yes  Mrnhan $\displaystyle \tan \frac{x}{2}$ is not defined at $\displaystyle x = \pi$
Thanks  Alraxite.
