<s>[INST] $\int_{C_N} \frac{dz}{z^2\sin(z)}$ complex integral, problem with residues 
Let $C_n$ be the rectangle, positively oriented, which sides are in the lines $$x=\pm(N+\dfrac{1}{2})\pi~~~y=\pm(N+\dfrac{1}{2})\pi$$
  with $N\in\mathbb{N}$. 
  Prove that 
  $$ \displaystyle\int_{C_N} \dfrac{dz}{z^2\sin(z)}=2\pi i\left[ \frac{1}{6}+2\sum_{n=0}^N \dfrac{(-1)^n}{n^2\pi^2}\right]  $$


what I did
If $f(z)=\dfrac{1 }{z^2\sin(z)}$ then $f$ has a pole of order 3 in $z=0$ so the value of the integral is equal to $2\pi i (\text{sum of residues}) $ so, it  gives me the factor $\frac{1}{6}$. then every point $z=n\pi, ~~ n=0,\pm1,\pm2,\cdots,\pm N$ are simple poles. my question is:
How i calculate the residues in those points? 
What am I missing? Am I doing it wrong? 
$$z^2\sin(z)=\displaystyle\sum_{n=0}^{\infty}(-1)^n\dfrac{z^{2n+3}}{(2n+1)!} $$
 [/INST] The function 
$$
f(z) = \frac{1}{z^2 \sin z} = \frac{1/z^2}{\sin z}
$$
has simple poles at $z = n\pi$, where $n \in \mathbb{Z}$, $n \neq 0$, so
$$
\newcommand{\Res}{\operatorname*{Res}\limits} \Res_{z=n\pi} f(z) = \frac{1/z^2}{\cos z} \Big|_{z=n\pi} = \frac{(-1)^n}{n^2\pi^2}.
$$
In particular, the residue at $n\pi$ is equal to the residue at $-n\pi$, so it's enough to sum over the positive integers up to $N$ and multiply by $2$. This leaves us with the residue at $z=0$. Here
\begin{align}
f(z) = \frac{1}{z^2\sin z} &= \frac{1}{z^2 ( z - \frac{z^3}{3!} + \cdots )} \\
&=\frac{1}{z^3} \cdot \frac{1}{1 - \frac{z^2}{3!} + \frac{z^4}{5!} - \cdots} \\
&= \frac{1}{z^3} \left(1 + \left( \frac{z^2}{3!} - \frac{z^4}{5!} - \cdots \right) - \left( \frac{z^2}{3!} - \frac{z^4}{5!} - \cdots \right)^2 + \cdots \right) \\
&= \frac{1}{z^3} + \frac{1}{6z} + \text{terms of positive degree}
\end{align}
where the series expansion is valid near $z=0$ (we use the Maclaurin series for $\sin z$ and the geometric series, keeping track of terms of degree $3$ or less). Hence
$$
\Res_{z=0} f(z) = \frac16,
$$
which gives you the final term in the sum.
</s>