The meaning of the Imaginary value of the Residue while Evaluating a Real Improper Integral When evaluating the improper integral $$\int_{0}^{\infty}\frac{x^{3}\sin\left(2x\right)}{\left(x^{2}+1\right)^{2}}\,dx$$ (which is an even function, so half of the $(-\infty,\infty)$ integral), I used the function $$\oint_{\gamma}\frac{iz^{3}e^{-2iz}}{\left(z^{2}+1\right)^{2}}\,dz,$$ over the upper half circle with the radius $r$ and then returning through the reals using the residue method (and made sure that when $r\to\infty$, the half circle's integral is $0$).
I found that:
$$\operatorname{Res}\left(\frac{iz^{3}e^{-2iz}}{\left(z^{2}+1\right)^{2}},i\right)=\left.\frac{d}{dz}\left(\frac{iz^{3}e^{-2iz}}{\left(z+i\right)^{2}}\right)\right|_{z=i}=ie^{2}$$
which means:
$$\int_{0}^{\infty}\frac{x^{3}\sin\left(2x\right)}{\left(x^{2}+1\right)^{2}}dx=\frac{1}{2}\int_{-\infty}^{\infty}\frac{x^{3}\sin\left(2x\right)}{\left(x^{2}+1\right)^{2}}dx=\frac{1}{2}\Re(ie^{2})=0.$$
While I evaluated the integral, I wanted to know: what does $\Im\left(\operatorname{Res}\left(f,i\right)\right)=e^2$ mean. Clearly not $\int_{-\infty}^{\infty}\frac{x^{3}\cos\left(2x\right)}{\left(x^{2}+1\right)^{2}}dx$, since it's an odd function which means the integral is zero.
Have I made a mistake anywhere? If not, what does $e^2$ mean?
 A: You made two mistakes, which together caused the non-sensical result.
You closed the contour with the wrong half circle. The integrand grows exponentially in that half plane; you need to use the lower half circle. The residue of the pole at $-i$ is zero.
The other mistake was that you omitted the factor $2\pi\mathrm i$ in applying the residue theorem.
A: You have made two mistakes.
First, since $\lvert e^w\rvert = e^{\operatorname{Re} w}$, the function $z \mapsto e^{-2iz}$ grows exponentially as $\operatorname{Im} z \to +\infty$, so you can't deduce that the integral over the semicircle in the upper half-plane tends to $0$ as the radius of the semicircle tends to $+\infty$. You can use a semicircle in the lower half-plane, or you can use $e^{2iz}$.
Second, you forgot the factor $2\pi i$ of the residue theorem.
If we use the semicircle in the upper half-plane, and
$$\int_0^{+\infty} \frac{x^3\sin (2x)}{(x^2+1)^2}\,dx = \frac{1}{2} \int_{-\infty}^{+\infty} \frac{x^3 e^{2ix}}{i(x^2+1)^2}\,dx$$
by parity and $e^{2ix} = \cos (2x) + i \sin (2x)$, then we find
$$\int_0^{+\infty} \frac{x^3\sin (2x)}{(x^2+1)^2}\,dx = \frac{2\pi i}{2} \operatorname{Res}\biggl( \frac{z^3e^{2iz}}{i(z^2+1)^2}; i\biggr) = \pi \operatorname{Res}\biggl(\frac{z^3e^{2iz}}{(z^2+1)^2}; i\biggr).$$
Now, the residue is $0$, and it so happened that the effects of your mistakes cancelled and you got the correct result for your integral, but that was coincidence.
If you had only made the first error and not forgot the factor $2\pi i$, then you would have obtained
$$\pi i \operatorname{Res}\biggl(\frac{iz^3 e^{-2iz}}{(z^2+1)^2}; i\biggr) = -\pi e^2$$
as the (incorrect) result. That is, as we now see, just half of
$$\lim_{r \to \infty} \int_{\substack{\lvert z\rvert = r \\ \operatorname{Im} z > 0}} \frac{iz^3e^{-2iz}}{(z^2+1)^2}\,dz.$$
