Residue calculation of $e^z \csc^2(z)$ Find all the residue of $f(z)= e^z\csc^2(z)$ at all its pole in the finite plane.
My attempt- $z=n\pi, n \in \mathbb{Z}$ are the set of poles, each of order 2. Therefore residue will be $$\operatorname{Res}(z=n\pi)= \lim_{z\to n\pi}\frac{1}{1!}\frac{d}{dz} \frac{(z-n\pi)^2 e^z}{\sin^2(z)} $$ $$= \lim_{z\to n\pi}\frac{2\sin^2(z)(z-n\pi)e^z+ \sin^2(z)(z-n\pi)^2e^z- 2(z-n\pi)^2e^z\sin(z)\cos(z)}{\sin^4(z)}$$ $$=\lim_{z\to n\pi}\frac{2e^{n\pi}}{\sin(z)} + e^{n\pi} - \lim_{z\to n\pi}\frac{2e^{n\pi}\cos(z)}{\sin(z)} $$ $$=\begin{cases} e^{2m\pi}, z=2m, m\in \mathbb{Z} \\ \infty ,  z=2m+1, m\in \mathbb{Z}\end{cases}$$
I believe this result is wrong for odd integers as otherwise pole of order 2 has no meaning if residue is infinite. 
 A: Since$$\sin^2(z)=\sin^2(z-n\pi)=(z-n\pi)^2+o(z^3),$$you have\begin{align}\frac{e^z}{\csc^2z}&=\frac{e^{n\pi}e^{z-n\pi}}{\sin^2(z-n\pi)}\\&=e^{n\pi}\frac{1+(z-n\pi)+\cdots}{(z-n\pi)^2+\cdots}\\&=\frac{a_{-2}}{(z-n\pi)^2}+\frac{a_{-1}}{z-n\pi}+\cdots\\&=\frac{a_{-2}+a_{-1}(z-n\pi)+\cdots}{(z-n\pi)^2}\end{align}and it follows from the equality between the third and the fifth expressions that$$e^{n\pi}\bigl(1+(z-n\pi)+\cdots\bigr)(z-n\pi)^2=\bigl((z-n\pi)^2+\cdots\bigr)\bigl(a_{-2}+a_{-1}z+\cdots\bigr).$$So, $a_{-2}=a_{-1}=e^{n\pi}$ and$$\operatorname{res}_{n\pi}\left(\frac{e^z}{\csc^2z}\right)=a_{-1}=e^{n\pi}.$$
A: The last limit has been wrongly deduced. In fact it must be calculated as follows:
$$L=e^{n\pi}+2e^{n\pi}lim_{z\to n\pi}(z-n\pi)sinz[{{sinz-(z-n\pi)cosz}\over{sin^4z}}]$$$$=e^{n\pi}+2(-1)^ne^{n\pi}lim_{z\to n\pi}(z-n\pi)sin(z-n\pi)[{{(-1)^nsin(z-n\pi)-(z-n\pi)(-1)^n}\over{sin^4(z-n\pi)}}]$$$$=e^{n\pi}+2e^{n\pi}lim_{z\to n\pi}[{{sin(z-n\pi)-(z-n\pi)}\over{sin^2(z-n\pi)}}]$$
Using L'Hôpital's rule we obtain:
$$L=e^{n\pi}+2e^{n\pi}lim_{z\to n\pi}[{{cos(z-n\pi)-1}\over{sin2(z-n\pi)}}]$$$$=e^{n\pi}+2e^{n\pi}lim_{z\to n\pi}[{{-sin(z-n\pi)}\over{2cos2(z-n\pi)}}]=e^{n\pi}$$
