Computing the residue of a rational function The real integral I am trying to compute with residues/contour integration is
$\int_{-\infty}^{\infty}\frac{x^2}{(x^2+a^2)^3} \,dx$ For $a$ positive and by using the complex integral
$$\int_{C_R}\frac{z^2}{(z^2+a^2)^3} \,dz$$
For some arc bounding only the positive pole, $a i$. I am not sure how to evaluate this pole of order 3.
In class we have discussed how we can write a function $f(z)$ with a pole of order $n$ at $z_0$ multiplicatively as 
$$f(z)=\frac{g(z)}{(z-z_0)^n}$$ or additively as
$$f(z)=\frac{a_{-n}}{(z-z_0)^n}+\cdots+\frac{a_{-1}}{z-z_0}+h(z)$$
For holomorphic functions on a disc around the pole $h,g$, which I think is equivalent to finding a Laurent series 
This yields the formula for the residue
$$\text{Res}(f,z_0)=\lim_{z\rightarrow z_0}\frac{1}{(n-1)!}\frac{d^{n-1}}{dz^{n-1}}[
  (z-z_0)^nf(z)]$$
Which gets messy. Is there a more elegant way?
 A: Your calculation of the derivative is unnecessarily complicated. The reason we're multiplying by $(z-z_0)^n$ is that this is a factor in the denominator; so you can cancel it from the denominator:
\begin{align}
\operatorname{Res}(f,z_0)&=\lim_{z\to z_0}\frac1{(n-1)!}\frac{\mathrm d^{n-1}}{\mathrm dz^{n-1}}\left[
  (z-z_0)^nf(z)\right]
\\
&=\lim_{z\to a\mathrm i}\frac12\frac{\mathrm d^2}{\mathrm dz^2}\left[
  (z-a\mathrm i)^3\frac{z^2}{\left(z^2+a^2\right)^3}\right]
\\
&=
\lim_{z\to a\mathrm i}\frac12\frac{\mathrm d^2}{\mathrm dz^2}\frac{z^2}{(z+a\mathrm i)^3}
\\
&=\lim_{z\to a\mathrm i}\frac12\left(\frac2{(z+a\mathrm i)^3}-2\cdot\frac{6z}{(z+a\mathrm i)^4}+\frac{12z^2}{(z+a\mathrm i)^5}\right)
\\
&=\frac{\mathrm i}{2a^3}\left(\frac14-\frac34+\frac38\right)
\\
&=-\frac{\mathrm i}{16a^3}\;.
\end{align}
A: After two failed attempts, and since it looks like no one has proposed Taylor series method, which is my favourite, I can't resist posting this not-so-elegant answer.
Computationally this answer might not be the most economical one, but I think in general it should be less painful than differentiating twice or even more. So here it goes
\begin{align}
  f(z) &=\frac{z^2}{(z^2+a^2)^3} = \frac{1}{(z-ai)^3}\frac{(z-ai+ai)^2}{(z-ai+2ai)^3} \\
  & = \frac{1}{(z-ai)^3}\frac{(ai)^2}{(2ai)^3}\frac{(1+\frac{z-ai}{ai})^2}{(1+\frac{z-ai}{2ai})^3} \\
  & = \frac{1}{(z-ai)^3}\frac1{8ai}(1+2\frac{z-ai}{ai}+\frac{(z-ai)^2}{(ai)^2})(1-3\frac{z-ai}{2ai}+6\frac{(z-ai)^2}{(2ai)^2}+O(|z-ai|^3)).\\
\end{align}
Note that in the last equality we have used the Newton formula $$(1+w)^{-3}=1-3w+6w^2+O(|w|^3),$$ for small $w$.
Now, we see that $f(z)$ is $\frac{1}{(z-ai)^3}$ times lots of other stuff. But all we want is only the residue, so anyway amid all that stuff all we need are terms of magnitude of $(z-ai)^2$ (which is also why we only need to expand up to $O(|w|^3)$ in the Newton formula). Pick out all the needed terms from that stuff (which is essentially a very simple combinatoric task), we get
\begin{align}
  f(z) & = \frac{1}{(z-ai)^3} \frac1{8ai}(6\frac1{(2ai)^2}-2\cdot 3\frac{1}{2(ai)^2}+\frac{1}{(ai)^2}+\cdots) \\
       & = \frac{1}{(z-ai)^3} \frac1{8(ai)^3} (-\frac12(z-ai)^2+\cdots),
\end{align}
which yields our desired results as 
$$\text{Res}(f,ai)=\frac1{16a^3 i}.$$
A: @joriki posted the same answer I was going to before I could get it typed in, so I'll just post the second half:
$$\begin{align}\int_{-\infty}^{\infty}\frac{x^2}{(x^2+a^2)^3}dx&=\frac2{a^3}\int_0^{\infty}\frac{y^2}{(y^2+1)^2}dy=\frac1{a^3}\int_0^{\infty}\frac{z^{\frac12}}{(z+1)^3}dz\\
&=\frac1{a^3}\int_0^1(1-t)^{\frac12}t^{\frac12}dt=\frac1{a^3}\text{B}\left(\frac32,\frac32\right)\\
&=\frac1{a^3}\frac{\Gamma\left(\frac32\right)\Gamma\left(\frac32\right)}{\Gamma(3)}=\frac1{a^3}\frac{\left(\frac12\pi\right)\left(\frac12\pi\right)}{2}=\frac{\pi}{8a^3}\end{align}$$
In the above we have made the successive substitutions $x=ay$, $y^2=z$, and $t=1/(z+1)$ and made use of the symmetry of the original integral. Then I made use of the properties of the Beta and Gamma function.
So this provides a useful check of the contour integration results.
A: Computing the residue as @joriki suggested
\begin{align*}
  \text{Res}(f,z_0)&=\lim_{z\rightarrow z_0}\frac{1}{(n-1)!}\frac{d^{n-1}}{dz^{n-1}}[
  (z-z_0)^nf(z)]\\
  &\Rightarrow   \text{Res}(f,ai)=\frac{1}{2}\lim_{z\rightarrow ai}\frac{d^2}{dz^2}
  [(z-ai)^{3}\frac{z^2}{(z^2+a^2)^3}]=
  \frac{1}{2}\lim_{z\rightarrow ai}\frac{d^2}{dz^2}
  [(z-ai)^{3}\frac{z^2}{(z-ai)^3(z+ai)^3}]\\
  &=\frac{1}{2}\lim_{z\rightarrow ai}\frac{d^2}{dz^2}
  [\frac{z^2}{(z+ai)^3}]=\frac{1}{2}\lim_{z\rightarrow ai}\frac{d}{dz}
  [\frac{z(2ai-z)}{(z+ai)^4}]\\
  &=\frac{1}{2}\lim_{z\rightarrow ai}\frac{2(ai-z)}{(z+ai)^4}
  -4\frac{z(2ai-z)}{(z+ai)^5}=
  -4\frac{1}{2}\lim_{z\rightarrow ai}\frac{z(2ai-z)}{(z+ai)^5}\\
  &=-2\frac{(ai)^2}{(2ai)^5}=\frac{1}{16ia^3}
\end{align*}
yielding then for our integral:
\begin{align*}
    \int_{C_R}\frac{z^2}{(z^2+a^2)^3}dz&=2\pi i  \text{Res}(f,ai)=\frac{2\pi i}{16ia^3}
    =\frac{\pi}{8a^3}
\end{align*}
Now, to send the arc legnth to zero, we parametrize the arc as usual $\gamma_R(t)=Re^{it}$, $t\in [0,\pi]$,
and bounding our integrand using the max and path length
\begin{align*}
  |\int_{\gamma_R}\frac{z^2}{(z^2+a^2)^3}&|\leq
  \max_{|z|=R}|\frac{z^2}{(z^2+a^2)^3}|*||\gamma_R(t)||=
  \frac{R^2}{(R^2+a^2)^3}\pi R\sim cR^{-3}\rightarrow 0\;\text{as}\;
  R\rightarrow \infty
\end{align*}
Yielding our answer:
\begin{align*}
  \lim_{R\rightarrow \infty}\int_{-R}^{R}\frac{z^2}{(z^2+a^2)^3}dz=\int_{-\infty}^{\infty}\frac{z^2}{(z^2+a^2)^3}dz=\frac{\pi}{8a^3}
\end{align*}
