Example using Cauchy's Theorem and integrating over a contour This is an example out of Stein and Shakarachi Complex Analysis.  My question is, Why do they choose $f(z) = \frac{(1 - e^{iz})}{z^2}?$  


The difficult part of doing this integral by complex analysis is that $\cos{z}$ blows up as the imaginary part of $z$ becomes large:
$$ 2\cos{(x+iy)} = e^{ix}e^{-y}+e^{-ix}e^{y}, $$
so the second term is exponentially increasing as $y \to +\infty$. In order to use a contour like the one in the picture (which is the only known contour that works for such a function, as far as I know), we need to have a function that decays faster than $|z|^{-1}$ as $|z|$ becomes large. The way to do this is to remember that $ \Re(e^{iz}) = \cos{z} $, and $e^{iz}$ behaves nicely in the upper half-plane:
$$ e^{i(x+iy)} = e^{ix}e^{-y} \to 0 \quad \text{as } y\to \infty, $$
so the integrand is bounded above by $2/R^2$, so the integral over $\gamma_R^+$ tends to zero, as noted in the proof. You couldn't do this if you kept a $\cos{z}$ in the numerator.
