How to calculate this complex integral: $\int_0^{2\pi}\cot(t-ia)dt$, where $a>0$. How to calculate this complex integral?
$$\int_0^{2\pi}\cot(t-ia)dt,a>0$$
I got that the integral is $2\pi i$ if $|a|<1$ and $0$ if $a>1$
yet, friends of mine got $2\pi i$ regardless the value of $a$.
looking for the correct way
 A: 
so, I'll use the residue theorem

Be careful. You need a closed contour for the residue theorem, but the interval $[0,2\pi]$ isn't a closed contour.
There are of course several methods to evaluate the integral. One particularly nice way, since $\cos = \sin'$ and $\sin$ is $2\pi$-periodic, is
$$\int_0^{2\pi} \cot (t-ia)\,dt = \int_0^{2\pi} \frac{\sin'(t-ia)}{\sin (t-ia)}\,dt = \int_\gamma \frac{dz}{z} = 2\pi i\cdot n(\gamma,0),$$
where $\gamma \colon [0,2\pi] \to \mathbb{C}\setminus \{0\}$ is the closed curve $t\mapsto \sin (t-ia)$.
The addition theorem yields
$$\gamma(t) = \sin t\cosh a - i\cos t \sinh a,$$
so $\gamma$ is an ellipse with centre $0$ and semiaxes $\sinh a$ and $\cosh a$, traversed once in the positive sense. Hence $n(\gamma,0) = 1$ for all $a > 0$, and the integral is $2\pi i$ for all $a > 0$.
Another method is to write
$$\cot (t-ia) = \frac{\cos t\cosh a + i\sin t \sinh a}{\sin t \cosh a - i \cos t \sinh a},$$
and then write $z = e^{it}$, so substitute $\cos t = \frac12(z+z^{-1})$ and $\sin t = \frac{1}{2i}(z-z^{-1})$, and apply the residue theorem to the integral
$$\int_{\lvert z\rvert = 1} \frac{(z+z^{-1})\cosh a + (z-z^{-1})\sinh a}{(-i)[(z-z^{-1})\cosh a + (z+z^{-1})\sinh a]}\,\frac{dz}{iz}$$
over the unit circle. The integrand simplifies to
$$\frac{z^2 e^a + e^{-a}}{z\left(z^2 e^a - e^{-a}\right)} = \frac{z^2 + e^{-2a}}{z(z-e^{-a})(z+e^{-a})},$$
and the residues in $\pm e^{-a}$ are easily seen to cancel, leaving only the residue in $0$, which is $1$.
A: Expand the cotangent to get that the integral is a ratio of sines and cosines:
$$\int_0^{2 \pi} dt \frac{\cosh{a} \cos{t} + i \sinh{a} \sin{t}}{\cosh{a} \sin{t} - i \sinh{a} \cos{t}} $$
Now use the usual $z=e^{i t}$, $dt = -i dz/z$ to get the integral is equal to
$$\oint_{|z|=1} \frac{dz}{z} \frac{e^a z^2+e^{-a}}{e^a z^2-e^{-a}}$$
Assume $a \gt 0$; then the poles of the integrand that lie within the unit circle are at $z=0$ and $z=\pm e^{-a}$.  The residues from these poles are, respectively, $-1$, $1$, and $1$, so that the sum of the residues is $1$ and the integral is, by the residue theorem, $i 2 \pi$.  
Note that when $a \lt 0$, the only pole within the unit circle is at the origin, so the sum of the residues in that case is $-1$.  Thus, the value of the integral is
$$\int_0^{2 \pi} dt \, \cot{(t-i a)} = i 2 \pi \, \operatorname*{sgn}{a} \quad (a \ne 0)$$
