Using residues to evaluate an improper integral 
Use residues to evaluate the improper integral
  \begin{align}
\int_{0}^{\infty} \frac{1}{(x^2+1)^2} \, dx
\end{align}

First, I said $f(z) = \frac{1}{(z^2+1)^2}$. My only question so far is how do I establish the region $C$ (from the given real limits of $0$ to $\infty$) so I can do countour integration and find residues in $C$?
 A: First recognize that since your integrand is even, you have
$$\frac{1}{2}\int_{-\infty}^{\infty} \frac{1}{(1+x^2)^2}dx = \int_0^{\infty}\frac{1}{(1+x^2)^2}dx.$$
Then use the residue theorem with a semicircular contour in the upper (or lower) half plane. Of course you will need to argue that the integral along the semicircular arc goes to zero.
If you look at the image below, you'll see that as $a\rightarrow\infty$, you'll be integrating over the whole real line plus a semicircular arc at infinity:

This is the true reason we do the semicircular contour. Let's set up our semicircular contour: $\gamma(t) = [-R,R]\cup\{Re^{it}:0\le t\le\pi\}$. This parameterizes the above contour. Let's integrate over this. Define $I_R$ by
$$I_R = \int_{\gamma} \frac{1}{(1+z^2)^2}dz = \int_{-R}^R\frac{1}{(1+x^2)^2}dx + \int_0^{\pi} \frac{1}{(1+(Re^{it})^2)^2}iRe^{it}dt.$$
As we take $R\rightarrow\infty$, notice that we would get the integral we were interested in to begin with.
A: In response to @Cameron Williams' hint and comments, I am going to attempt the solution.
We have $f(z) = \frac{1}{(z^2+1)^2}$. Let $C$ be the half circle as described by @Cameron Williams. Now, we have $z = i$ to be the singularity point inside $C$. 
In finding the residue,
\begin{align}
\text{Res}_{z = i} f(z) &= \text{Res}_{z = i} \frac{1}{(z^2+1)^2} = \text{Res}_{z = i} \frac{1}{(z+i)^2(z-i)^2} \\
&= \frac{d}{dz} \frac{1}{(z+i)^2} \Bigg\vert_{z=i} = -\frac{2}{(z+i)^3} \Bigg\vert_{z=i} = \frac{1}{4i}
\end{align}
For the horizontal line and half-circle arc, we have $z = x$ and $z=Re^{i \theta}$ respectively. Employing the residue theorem for integrals, we have
\begin{align}
\int_C f(z) \, dz = \int_{-R}^{R} \frac{1}{(x^2+1)^2} \, dx + \int_{0}^{\pi} \frac{1}{(Re^{i \theta}+1)^2} (iRe^{i \theta} \, d\theta) = 2\pi i \, \text{Res}_{z = i} f(z) = \frac{\pi}{2}
\end{align}
Taking the limit as $R \rightarrow \infty$, we get
\begin{align}
\int_{-\infty}^{\infty} \frac{1}{(x^2+1)^2} \, dx + 0 = \frac{\pi}{2}
\end{align}
Therefore,
\begin{align}
\int_{0}^{\infty} \frac{1}{(x^2+1)^2} \, dx = \frac{\pi}{4}
\end{align}
A: Hint. Try $\gamma=\gamma_1\cup\gamma_2$, where
$$
\gamma_1(t)=t, \,\,\,t\in[-R,R],
$$ 
and 
$$
\gamma_2(t)=R\,\mathrm{e}^{it},\,\,\,t\in[0,\pi],
$$
and let $R\to\infty$.

 Answer. $\int_0^\infty \frac{dx}{(1+x^2)^2}=\frac{\pi}{4}$.

