Solution (source code)

= Solution

On the <unit circle>, put $z=e^{i\theta}$. Then $d\theta=dz/(iz)$ and $\cos\theta=(z+z^{-1})/2$, so
$$
\frac{d\theta}{(2-\cos\theta)^2}
=\frac4i\frac{z\,dz}{(z^2-4z+1)^2}.
$$
Write $r=2-\sqrt3$ and $s=2+\sqrt3$. Only $r$ lies inside the <unit circle>; the <rational function> $h(z)=z/[(z-r)^2(z-s)^2]$ has a double <pole> there. Its <residue> is
$$
\operatorname{Res}_{z=r}h
=\left.\frac{d}{dz}\frac{z}{(z-s)^2}\right|_{z=r}
=\frac1{(r-s)^2}-\frac{2r}{(r-s)^3}
=-\frac{r+s}{(r-s)^3}=\frac1{6\sqrt3}.
$$
By the <residue theorem>,
$$
\boxed{\int_0^{2\pi}\frac{d\theta}{(2-\cos\theta)^2}
=\frac4i\,2\pi i\frac1{6\sqrt3}=\frac{4\pi}{3\sqrt3}.}
$$