$\int \frac{\cos x}{x} dx $ using contour integration I saw a solution of how to use complex analysis to integrate
$\int_{-\infty}^{\infty} \frac{\cos x}{x} dx$ which uses the contour that traverses an upper semi circle of radius $R$ in the positive direction followed by the line segment from $-R$ to $-\epsilon$ then the upper semi circle of radius $\epsilon$ in the negative direction followed by the line segment from $\epsilon$ to $R$. Everything makes sense to me except computing $\lim_{\epsilon \rightarrow 0} \int_{C_\epsilon} \frac{e^{iz}}{z}dz$. Everywhere I have looked, the limit is computed by taking the limit inside the integral. Why can this be done? I think it has to do with dominated convergence but what is the dominating integrable function?
Thanks in advance.
 A: This is a shameless adaptation from my own set of notes, but it does help (me) tie a few things together mentioned in the relevant PDF linked below the question.
Consider the principal value integral \begin{equation}\label{principalval}I = \text{P} \int_{-\infty}^\infty \frac{f\left(x\right) \: dx}{x-x_0} \:,\end{equation} where by shifting $x \rightarrow z$, we assume that $f\left(z\right)$ is analytic except for a finite number of poles, and that $\left|f\right| \rightarrow 0$ on the upper (or lower) infinite semicircle in the complex plane.
Since the pole $x_0$ lies on the real axis, the integration contour cuts directly through $x_0$. This is handled by regularization of the denominator, which entails introducing a small factor $\delta>0$ as $$I = \text{P} \int_{-\infty}^\infty \frac{f\left(x\right) \: dx}{x-x_0} = \lim_{\delta\rightarrow 0} \int_{-\infty}^\infty \frac{\left(x-x_0\right)f\left(x\right) \: dx}{\left(x-x_0\right)^2 + \delta^2} = \lim_{\delta\rightarrow 0} \oint_C \frac{\left(z-x_0\right)f\left(z\right) \: dz}{\left(z-x_0\right)^2 + \delta^2} \:.$$ After a little complex algebra, find $$I = \lim_{\delta\rightarrow 0} \oint_C \frac{f\left(z\right) \: dz}{z-x_0+i\delta} + \lim_{\delta\rightarrow 0} \oint_C i\delta \frac{f\left(z\right) \: dz}{\left(z-x_0-i\delta\right)\left(z-x_0+i\delta\right)} \:,$$ which indicates one simple pole $z_0 = x_0 + i\delta$ inside the upper-half plane. The first integral in fact excludes the pole, so $x_0$ is skipped in subsequent residue calculations. (Use the $\delta$-term as a reminder to skip $x_0$.) The second integral is solved by standard residue calculus, i.e., let $g\left(z\right)=f\left(z\right)/\left(z-x_0+i\delta\right)$, resulting in $\pi i f\left(x_0\right)$.
Pulling the results together, we write \begin{equation}\label{principalvaltwoterms}I^+ = \pi i f\left(x_0\right) + \lim_{\delta\rightarrow 0} \oint_C \frac{f\left(z\right) \: dz}{z-x_0+i\delta} \:,\end{equation} where if we started with $\delta<0$ instead, the integration contour would flip to the lower-half plane, resulting in $$I^- = -\pi i f\left(x_0\right) + \lim_{\delta\rightarrow 0} \oint_C \frac{f\left(z\right) \: dz}{z-x_0-i\delta} \:.$$ In tighter notation (regardless of path or the sign of $\delta$), one may write \begin{equation}\label{principalvalcomplex}I = \text{P} \int_{-\infty}^\infty \frac{f\left(x\right) \: dx}{x-x_0} = \text{P} \oint_C \frac{f\left(z\right) \: dz}{z-x_0} \:,\end{equation} reminding us to include $x_0$ inside integration contour, but take the residue with a factor of $1/2$.
So for instance, to evaluate $$I = \int_{-\infty}^\infty \frac{\sin x}{x} \: dx \:,$$ the answer is almost too trivial to show off the method, but here it is:
$$I = \text{Im} \left( \pi i \: e^{i \cdot 0} + \lim_{\delta\rightarrow 0} \oint_C \frac{e^{iz} \: dz}{z+i\delta} \right) = \text{Im} \left( \pi i \: e^{i \cdot 0} + 0 \right) = \pi$$
By the same apparatus, we can show the cosine-version to be zero.
A: To be completely rigorous and apply the dominated convergence theorem, we need to convert the function family $\{e^{ire^{i\theta}}\}_{r>0}$ to a sequence $\{e^{\frac{i}{n}e^{i\theta}}\}_{n=1}^{\infty}$ via the change of variable $r=\frac{1}{n}$. Keeping in mind that we are on the measure space $[-\pi,0]$, it is not too hard to see that $|e^{-\frac{1}{n}\sin\theta}| \leq e^{-\sin\left(\frac{-\pi}{2}\right)} = e$ on our measure space. So now we are ready to show the crucial inequality which will allow us to apply the dominated convergence theorem:
$$|e^{\frac{i}{n}e^{i\theta}}| = |e^{-\frac{1}{n}\sin\theta}| < e \text{ for all } n \in \mathbb{N} \text{ and } \theta \in [-\pi,0]$$
Thus, we can use the constant function $g \equiv e$ as our dominating function. This is integrable because we are on a finite measure space.
