Contour Integration Question I am reading a computation that $\int_{0}^{\infty} \frac{1 - \cos x}{x^{2}}\, dx = \frac{\pi}{2}.$ They integrate over the indented semicircle. Let $R_{\varepsilon}$ be the semicircle in the upper half plane of radius epsilon around the origin going from $-\varepsilon$ to $\varepsilon$. My question is: what is the reasoning behind the following statement:
$$\int_{R_{\varepsilon}}\frac{1 - e^{iz}}{z^{2}}\, dz \rightarrow \int_{\pi}^{0}(-ii)\, d\theta = -\pi$$
as $\varepsilon \rightarrow 0$.
 A: Since $z = -\epsilon \mathrm{e}^{-i \phi}$, where $\phi$ varies from $0$ to $\pi$. Then $\mathrm{d} z = i \epsilon \, \mathrm{e}^{-i \phi} \mathrm{d} \phi$, so 
$$
   \int_{R_\epsilon} \frac{1 - \mathrm{e}^{i z}}{z^2} \mathrm{d} z = \int_0^\pi 
      \frac{ 1-\exp( -i \epsilon \mathrm{e}^{-i \phi} )}{ \epsilon^2 \mathrm{e}^{-2 i \phi}} (i \epsilon \, \mathrm{e}^{-i \phi} ) \mathrm{d} \phi =
  \int_0^\pi 
      \frac{ 1-\exp( -i \epsilon \mathrm{e}^{-i \phi} )}{ \epsilon} (i  \,  \mathrm{e}^{i \phi} ) \mathrm{d} \phi
$$ 
Now, as $\epsilon \to 0$, $\frac{ 1-\exp( -i \epsilon \mathrm{e}^{-i \phi} )}{ \epsilon} \sim i \, \mathrm{e}^{-i \phi} + o(\epsilon) $, thus
$$
  \int_0^\pi 
      \frac{ 1-\exp( -i \epsilon \mathrm{e}^{-i \phi} )}{ \epsilon} (i  \,  \mathrm{e}^{i \phi} ) \mathrm{d} \phi \to \int_0^\pi \left( i \, \mathrm{e}^{-i \phi} \right) ( i \,  \mathrm{e}^{i \phi}) \mathrm{d} \phi = \int_0^\pi (i)^2 \mathrm{d} \phi = -\pi
$$
A: Consider the Laurent series
$$
\frac{1-e^{iz}}{z^2}=-\frac{i}{z}+\frac{1}{2}+\frac{iz}{6}-\frac{z^2}{24}-\dots
$$
The only part that doesn't vanish as $\epsilon\to0$ is $-\frac{i}{z}$. The integral of $\frac{1}{z}$ is $\log(z)=\log|z|+i\arg(z)$.  Since $\arg(z)$ drops by $\pi$ over $R_\epsilon$ (and $|z|$ doesn't change), we get that the integral is $(-i)(-i\pi)=-\pi$. In the statement you cite, it looks as if they have converted the integral of $-\frac{i}{z}$ to polar coordinates:
$$
\begin{align}
\int_{R_\epsilon}-\frac{i}{z}\;\mathrm{d}z
&=\int_\pi^0\frac{-i}{r}e^{-i\theta}\;\mathrm{d}re^{i\theta}\\
&=\int_\pi^0-ie^{-i\theta}ie^{i\theta}\;\mathrm{d}\theta\\
&=\int_\pi^0-ii\;\mathrm{d}\theta\\
\end{align}
$$
