Use contour integral to show $\int_0^{2\pi}\frac{\mathrm dt}{(1+\cos(u)\cos(t))^2}=\frac{2\pi}{\sin^3(u)}$ for $u\in(0,\frac{\pi}{2})$ I would like to show using contour integrals that $\int_0^{2\pi}\dfrac{\mathrm dt}{(1+\cos(u)\cos(t))^2}=\dfrac{2\pi}{\sin^3(u)}$ for any $u\in(0,\frac{\pi}{2})$. 
I first notice that $\cos(u)\in(0,1)$, so that $\cos(u)\cos(t)\neq -1$.
If I introduce the complex variable $z=\cos(t)+i\sin(t)$, then $z^{-1}=\cos(t)-i\sin(t)$ and $\cos(t)=\dfrac{z+z^{-1}}{2}$. Now, $\dfrac{\mathrm dz}{\mathrm dt}=-\sin(t)+i\cos(t)=iz$, so $\mathrm dt=\dfrac{\mathrm dz}{iz}$. Now, I want to use the definition of a integral over a curve, i.e. $\displaystyle\int_\gamma f(z)\,\mathrm dz=\int_{a}^{b}f(\gamma(t))\gamma'(t)\,\mathrm dt$, where $\gamma\colon[a,b]\to U\subset\mathbb{C}$ is a closed curve. But I have difficulites to match the expressions and to continue calculating the integral. 
 A: Let $$I(u):=\int_0^{2\pi}\,\frac{\text{d}t}{\big(1+\cos(u)\,\cos(t)\big)^2}\,.$$
Note that $I\left(\frac{\pi}{2}\right)=2\pi=I\left(\frac{3\pi}{2}\right)$, which agrees with the formula $I(u)=\frac{2\pi}{\left|\sin^3(u)\right|}$ for $u\in\left\{\frac{\pi}{2},\frac{3\pi}{2}\right\}$.   From now on, we assume that $u\in(0,2\pi)\setminus\left\{\frac{\pi}{2},\frac{3\pi}{2}\right\}$.
Let $z:=\cos(t)+\text{i}\,\sin(t)$; then,
$$I(u)=\oint_\gamma\,\frac{4\,z}{\text{i}\,\left(z^2+2\,\sec(u)\,z+1\right)^2}\,\text{d}z\,,$$
where $\gamma$ is the positively oriented unit circle $\big\{w\in\mathbb{C}\,\big|\,|w|=1\big\}$.  That is,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\oint_\gamma\,\frac{z}{\big(z+\sec(u)-\tan(u)\big)^2\,\big(z+\sec(u)+\tan(u)\big)^2}\,\text{d}z\,.$$ 
Write $u_+:=-\sec(u)+\tan(u)$ and $u_-:=-\sec(u)-\tan(u)$.  Define
$$f_u(z):=\frac{z}{\big(z^2+2\,\sec(u)\,z+1\big)^2}=\frac{z}{\big(z+\sec(u)-\tan(u)\big)^2\,\big(z+\sec(u)+\tan(u)\big)^2}\,.$$
You can write $$(z-u_+)^2\,f_u(z)=\frac{z}{\left(z-u_-\right)^2}$$
so that
$$\left.\frac{\text{d}}{\text{d}z}\right|_{z=u_+}\,\big((z-u_+)^2\,f_u(z)\big)=-\frac{u_++u_-}{(u_+-u_-)^3}=+\frac{\cos^2(u)}{4\,\sin^3(u)}\,.$$
Similarly, you can write $$(z-u_-)^2\,f_u(z)=\frac{z}{\left(z-u_+\right)^2}$$
so that
$$\left.\frac{\text{d}}{\text{d}z}\right|_{z=u_-}\,\big((z-u_-)^2\,f_u(z)\big)=-\frac{u_-+u_+}{(u_--u_+)^3}=-\frac{\cos^2(u)}{4\,\sin^3(u)}\,.$$
If $u\in\left(0,\frac{\pi}{2}\right)$, then $u_-<-1<u_+<0$.  Hence, by the Residue Theorem,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\Biggl(2\pi\text{i}\,\text{Res}_{z=u_+}\big(f(z)\big)\Biggl)=\frac{8\pi}{\cos^2(u)}\,\left(+\frac{\cos^2(u)}{4\,\sin^3(u)}\right)=+\frac{2\pi}{\sin^3(u)}\,.$$
If $u\in\left(\frac{\pi}{2},\pi\right)$, then $0<u_+<+1<u_-$.  Hence, by the Residue Theorem,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\Biggl(2\pi\text{i}\,\text{Res}_{z=u_+}\big(f(z)\big)\Biggl)=\frac{8\pi}{\cos^2(u)}\,\left(+\frac{\cos^2(u)}{4\,\sin^3(u)}\right)=+\frac{2\pi}{\sin^3(u)}\,.$$
If $u\in\left(\pi,\frac{3\pi}{2}\right)$, then $0<u_-<+1<u_+$.  Hence, by the Residue Theorem,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\Biggl(2\pi\text{i}\,\text{Res}_{z=u_-}\big(f(z)\big)\Biggl)=\frac{8\pi}{\cos^2(u)}\,\left(-\frac{\cos^2(u)}{4\,\sin^3(u)}\right)=-\frac{2\pi}{\sin^3(u)}\,.$$
If $u\in\left(\frac{3\pi}{2},2\pi\right)$, then $u_+<-1<u_-<0$.  Hence, by the Residue Theorem,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\Biggl(2\pi\text{i}\,\text{Res}_{z=u_+}\big(f(z)\big)\Biggl)=\frac{8\pi}{\cos^2(u)}\,\left(-\frac{\cos^2(u)}{4\,\sin^3(u)}\right)=-\frac{2\pi}{\sin^3(u)}\,.$$
In all cases,
$$I(u)=\frac{2\pi}{\left|\sin^3(u)\right|}=2\pi\,\left|\text{csc}^3(u)\right|\text{ for all }u\in\mathbb{R}\setminus \pi\mathbb{Z}\,.$$

In general,
$$\int_0^{2\pi}\,\frac{\text{d}t}{\big(1+r\,\sin(t)\big)^2}=\int_0^{2\pi}\,\frac{\text{d}t}{\big(1+r\,\cos(t)\big)^2}=\frac{2\pi}{\big(\sqrt{1-r^2}\big)^3}$$
for every $r\in\mathbb{C}\setminus\big((-\infty,-1]\cup[+1,+\infty)\big)$.  Similarly,
$$\int_0^{2\pi}\,\frac{\text{d}t}{1+r\,\sin(t)}=\int_0^{2\pi}\,\frac{\text{d}t}{1+r\,\cos(t)}=\frac{2\pi}{\sqrt{1-r^2}}$$
for every $r\in\mathbb{C}\setminus\big((-\infty,-1]\cup[+1,+\infty)\big)$. Here, we pick the branch of $\sqrt{1-r^2}$ in such a way that $$\big|1-\sqrt{1-r^2}\big|<|r|$$ (i.e., the branch cuts are $(-\infty,-1]$ and $[+1,+\infty)$).  That is, for $r\in\mathbb{C}\setminus\big((-\infty,-1]\cup[+1,+\infty)\big)$, the complex number $\sqrt{1-r^2}$ is in the open half-plane containing complex numbers with positive real parts; in short, $$\text{Re}\big(\sqrt{1-r^2}\big)>0\text{ for every }r\in\mathbb{C}\setminus\big((-\infty,-1]\cup[+1,+\infty)\big)\,.$$
