Calculation of residues Let be $a\in\mathbb C\setminus\mathbb Z$ a fixed complex number, and define the following function:
$$f(z)=\frac{a\pi\cot\pi z}{z(a-z)}$$
It has simple poles in $z\in\mathbb Z\setminus\{0\}$ and in $z=a$, and a double pole in $z=0$. my textbook says that it is straightforward that:
$\operatorname{Res}(f,n)=\frac{a}{n(a-n)}\;\;$   for  $n\in\mathbb Z\setminus\{0\}$
$\operatorname{Res}(f,a)=-\pi\cot\pi a$
$\operatorname{Res}(f,0)=\frac{1}{a}$
but I don't understand why these fact are true.
 A: For simple poles, it's easy:
$Res(f,n) = \lim_{z\to n} (z-n)f(z) = \frac{a}{n(a-n)}$ for $n \in \mathbb Z$
Because $\lim_{z\to n} (z-n) \cot(\pi z) = \frac{1}{\pi}$.
We also have:
$Res(f,a) = \lim_{z\to a} (z-a)f(z) = -\pi \cot(\pi a)$
For the double pole in $b$, you can use the formula: 
$Res(f,b) = \lim_{z\to b} \frac{d}{dz} \left( (z-b)^2f(z) \right)$
$\frac{d}{dz}\left( (z-b)^2f(z) \right) = \frac{-\pi\,a\,z\,{\csc\left( z\right) }^{2}}{a-z}+\frac{\pi\,a\,z\,\cot\left( z\right) }{{\left( a-z\right) }^{2}}+\frac{\pi\,a\,\cot\left( z\right) }{a-z}$
So the limit seems to be $\frac{\pi}{a}$ and not $\frac1a$
A: Note that the residue of $\pi \cot (\pi z) g(z)$ at $z=n, n= 0, \pm1, \pm 2, \cdots$ is
$$\operatorname*{Res}_{z=n}\,\pi \cot (\pi z) g(z) = \lim_{z \to n} (z-n)\pi \cot (\pi z) g(z)=
\lim_{z \to n} \pi \left(\frac{z-n}{\sin (\pi z)}\right) \cos (\pi z) g(z)=g(n)$$
It follows that
$$\operatorname*{Res}_{z=n}\,f(z)\,=\frac{a}{n(a-n)}$$
The reason that I used a general $g(x)$ function is because this interesting residue formula comes in handy for series evaluations later on.

$$\operatorname*{Res}_{z=a}\, \frac{a\pi\cot(\pi z)}{z(a-z)}=\lim_{z \to a} (z-a)\frac{a\pi\cot(\pi z)}{z(a-z)}=-\lim_{z \to a}\frac{a\pi\cot(\pi z)}{z}=-\pi \cot (\pi a)$$

$$\operatorname*{Res}_{z=0}\,f(z)=\lim_{z \to 0} (z-0)\frac{a\pi\cot(\pi z)}{z(a-z)}=\lim_{z \to 0} \frac{a\pi\cot(\pi z)}{a-z}=\frac{1}{a}$$
