Using Jordan's Lemma for residue integration 
Evaluate
  \begin{align}
\int_{0}^{\infty} \frac{\cos(ax)}{x^2+1} \, dx
\end{align}

So far, I set $f(z) = \frac{1}{z^2+1}$, and the singularity point are $z = \pm i$. But I am using the top half-circle, so I only need to consider the pole $z=i$. Then $\text{Res}_{z=i} f(z) = \frac{1}{2i}$. 
However, a similar example suggests I need to find $\text{Res}_{z=i} f(z) e^{iaz}$ instead. I am confused as to why this is so; my book isn't explaining this section well to me. I'm guessing that $\cos(ax)$ is in the way.
 A: The problem with your idea to use $\cos z/(z^2+1)$ is that $\cos z$ is exponentially large on the imaginary axis, namely
$$
\cos z = \frac{e^{iz}+e^{-iz}}{2}
$$
so
$$
\cos iy = \frac{e^{-y}+e^{y}}{2}.
$$
Hence your function grows too fast to guarantee that the integral over a half-circle tends to $0$ as the radius tends to $\infty$. That's the reason why we choose
$$
f(z) = \frac{e^{iaz}}{z^2+1}
$$
instead. Note that $e^{iaz} = \cos az + i \sin az$, so the real part of this integral is what we are after. Furthermore, $\cos ax$ is an even function, hence
$$
\int_0^\infty \frac{\cos ax}{x^2+1}\,dx = \frac12 \operatorname{Re} \int_{-\infty}^\infty \frac{e^{iax}}{x^2+1}\,dx.
$$
Regarding the title, Jordan's lemma is not necessary here, the standard ML inequality is enough. Let's assume that $a > 0$ (you can reduce the problem to this case). Then
$$
|e^{iaz}| = |e^{ia(x+iy)}| = |e^{iax - ay}| = e^{-ay} \le 1
$$
as long as $y \ge 0$. Let $C_R^+$ be a semi-circle in the upper half-plane with radius $R$. Then
$$
\left| \int_{C_R^+} \frac{e^{iaz}}{z^2+1}\,dz \right| \le \frac{1}{R^2-1} \cdot \pi R.
$$
which tends to $0$ as $R\to\infty$ (by the usual "ML"-inequality).
Jordan's lemma is only required when "the rest of the integrand" decays as $1/R$, for example in
$$
\int_{-\infty}^\infty  \frac{x\sin x}{x^2+1}\,dx.
$$
