Order of pole and evaluating residue $f(z)=\frac{ze^{iz}}{z^2+a^2}$
I need to determine the order of the poles and compute the residues.
To compute this, we were told to (in general), write $f(z)=\frac{g(z)}{(z-z_0)^m}$ , and choose $g$ so that $m$ is minimized (a natural number -- this is the order of the pole), my issue is two fold:
1)How do we know, in general, that we have picked a $g$ which minimizes the order.
2) How do I handle this particular function (and others with essential singuarities).
I know I may also write $f(z) =\frac{ze^{iz}}{(z+ia)(z-ia)}$, so I know the singularities are $\frac{+}{ }ia$ and an 'essential singularitiy' (at infinity).  But not sure how to compute the residues....
EDIT:
$\lim_{z\to ∞} \frac{ze^{iz}}{z^2+a^2}=\lim_{z\to ∞} \frac{ze^{iz}}{z^2}=
\lim_{z\to ∞} \frac{e^{iz}}{z}=∞$
So I can't use the result for when the limit exists and is finite (zero or non-zero).  
 A: The practical advice to determine the order of a pole $w$ of a function $f(z)$ is the following: write $f(z)$ in the form \begin{equation} f(z)=\frac{g(z)}{(z-w)^m} \end{equation} where $g(w) \neq 0$, then $m$ is the order of the pole $w$.
In your example, you already have the function $f(z)$ in the nice form, for example for $w=ia$ pick $g(z)=\frac{z e^{iz}}{z+ia}$ which is clearly non-zero when evaluated in $z=ia$, thus the order of the pole $z=ia$ is 1.
By the way, I assumed $a \neq 0$, try to work out on your own what happens when $a=0$.
A: I think that in general one has to be able to factor the function enough as to see the picture around some pole. In this particular case, as we have a rational function times an entire one, we can do:
$$z^2+a^2=(z-ai)(z+ai)$$
and from here we have two (or three, if you want to subdivide (2)) cases:
$$(1)\;\;\;a=0\Longrightarrow f(z)=\frac{ze^{iz}}{z^2}=\frac{e^{iz}}{z}\Longrightarrow \operatorname{Res}_{z=0}(f)=\lim_{z\to 0}z\,f(z)=\lim_{z\to 0}e^{iz}=e^0=1$$
$$(2)\;\;\;a\neq 0\Longrightarrow \operatorname{Res}_{z=\pm ai}(f)=\lim_{z\to\pm ai}(z\mp ai)\,f(z)=\lim_{z\to \pm ai}\frac{ze^{iz}}{z\mp ai}=\frac{\pm aie^{\mp a}}{\pm 2ai}=\frac{e^{\mp a}}{2}$$
