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$.