Residue of $ f(z)= \tan^{n-1}(\pi z)$ at its singularities 
If $n$ is an even integer , locate all the singularities of $\displaystyle f(z)= \tan^{n-1}(\pi z)$ and find the residue at $z=1/2$.

For singularities of $f(z)$ we have , $\cos(\pi z)=0\implies z=n+\frac{1}{2}$ , where $n\in \mathbb Z$.
Now , $f$ has a pole of order $n-1$ at $z=1/2$.
So , $\displaystyle Res(f, 1/2)=\frac{1}{(n-2)!}\lim_{z\to 1/2}\frac{d^{n-2}}{dz^{n-2}}\left(z-\frac{1}{2}\right)^{n-1}f(z)=?$
Please help at this step.
 A: Here is a useful observation: The residues of a derivative are all $0$.
Depending on whether you have defined the residue via an integral or as the coefficient of $(z - z_0)^{-1}$ in the Laurent expansion, different proofs are more appropriate. Suppose $g$ is holomorphic on $U := D_r(z_0) \setminus \{z_0\}$. For the integral definition, we note that by the fundamental theorem of calculus we have
$$\int_{\gamma} g'(z)\,dz = g(b) - g(a)$$
if $\gamma$ is a path from $a$ to $b$ in $U$, so the integral over all closed paths in $U$ vanish, in particular
$$\operatorname{Res}(g';z_0) = \frac{1}{2\pi i} \int_{\lvert z-z_0\rvert = \rho} g'(z)\,dz = 0,$$
where $0 < \rho < r$. For the definition as the coefficient, expand $g$ into a Laurent series about $z_0$ and differentiate to see that the coefficient of $(z-z_0)^{-1}$ in the Laurent expansion of $g'$ is $0$.
Further, recall that $\tan' z = 1 + \tan^2 z$ and for $m \geqslant 2$ write
$$\tan^m (\pi z) = \tan^{m-2}(\pi z)\cdot \bigl(1 + \tan^2 (\pi z)\bigr) - \tan^{m-2} (\pi z) = \frac{1}{(m-1)\pi}\cdot \frac{d}{dz}\bigl( \tan^{m-1}(\pi z)\bigr) - \tan^{m-2} (\pi z).\tag{1}$$
By $(1)$ and the above observation, we have
\begin{align}
\operatorname{Res}\bigl(\tan^m(\pi z); z_0\bigr) &= \frac{1}{(m-1)\pi}\operatorname{Res}\biggl(\frac{d}{dz}\bigl( \tan^{m-1}(\pi z)\bigr); z_0\biggr) - \operatorname{Res}\bigl( \tan^{m-2}(\pi z); z_0\bigr)\\
&= - \operatorname{Res}\bigl( \tan^{m-2}(\pi z); z_0\bigr).
\end{align}
It follows that for even $n \geqslant 2$ we have
$$\operatorname{Res} \bigl(\tan^{n-1}(\pi z); z_k\bigr) = (-1)^{\frac{n}{2}-1} \operatorname{Res}\bigl(\tan (\pi z); z_k\bigr) = \frac{(-1)^{\frac{n}{2}}}{\pi}\tag{2}$$
at all singularities $z_k = k + \frac{1}{2},\, k\in\mathbb{Z}$ of $\tan^{n-1} (\pi z)$.
For even $n \leqslant 0$, $\tan^{n-1} (\pi z) = \cot^{\lvert n\rvert + 1} (\pi z)$, and via $\cot' z = -(1+\cot^2 z)$ we obtain the analogous recurrence
$$\cot^m (\pi z) = -\frac{1}{(m-1)\pi} \frac{d}{dz}\bigl(\cot^{m-1} (\pi z)\bigr) - \cot^{m-2} (\pi z)\tag{3}$$
with its consequence
$$\operatorname{Res} \bigl(\cot^m (\pi z); z_0\bigr) = -\operatorname{Res}\bigl(\cot^{m-2} (\pi z); z_0\bigr)$$
for $m \geqslant 2$. The singularities of $\tan^{n-1} (\pi z) = \cot^{\lvert n\rvert+1} (\pi z)$ are $z_k = k,\, k\in\mathbb{Z}$ for $n \leqslant 0$, and it follows that
$$\operatorname{Res}\bigl(\tan^{n-1} (\pi z);z_k\bigr) = \operatorname{Res}\bigl(\cot^{\lvert n\rvert+1} (\pi z); z_k\bigr) = (-1)^{\frac{n}{2}}\operatorname{Res}\bigl(\cot (\pi z); z_k\bigr) = \frac{(-1)^{\frac{n}{2}}}{\pi}\tag{4}$$
for even $n \leqslant 0$.
Note that $(2)$ and $(4)$ are the same formula, but the location of the singularities depends on the sign of $n-1$.
A: Let $n$ be any integer greater than $1$, and let $k$ be any integer.
Consider a rectangular contour with vertices at $ k \pm iR$, $(k+1) \pm iR$.
Integrating $\tan^{n-1}(\pi z)$ counterclockwise around this contour,  we get $$ \int_{k}^{k+1}\tan^{n-1} \left(\pi (t-iR) \right) \, \mathrm dt + \int_{-R}^{R}\tan^{n-1} \left(\pi (k+1+it) \right) \, i \, \mathrm dt - \int_{k}^{k+1} \tan^{n-1} \left(\pi(t+iR) \right) \, \mathrm dt$$
$$- \int_{-R}^{R} \tan^{n-1} \left(\pi (k+it) \right) \, i \, \mathrm dt = 2 \pi i \,  \text{Res}\left[\tan^{n-1} (\pi z), k + \frac{1}{2} \right]. $$
But since $\tan^{n-1}(\pi z)$ is $1$-periodic in the real direction, the second and fourth integrals cancel each other.
Also, as $\text{Im}(z) \to + \infty$, $\tan(\pi z) \to i$ uniformly.
Similarly,  as $\text{Im}(z) \to - \infty$, $\tan(\pi z) \to -i$ uniformly.
So letting $R \to \infty$, we're left with $$ \begin{align}\int_{k}^{k+1}(-i)^{n-1} \, dt - \int_{k}^{k+1} (i)^{n-1}  \, dt &= (-i)^{n-1} - (i)^{n-1} \\ &= -2i \sin \left( (n-1) \frac{\pi}{2}\right) \\ &= 2i \cos \left(\frac{n \pi}{2} \right) \\  &= 2 \pi i \, \text{Res}\left[\tan^{n-1} (\pi z), k + \frac{1}{2} \right]. \end{align}$$
Therefore, $$\text{Res}\left[\tan^{n-1} (\pi z), k + \frac{1}{2} \right] = \frac{\cos \left(\frac{n \pi}{2} \right)}{\pi} .$$

This approach was discussed on mathforum.org back in 2003, but that section of the site was apparently not archived.
