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}?$  

 A: $f(z) = \frac{(1 - e^{iz})}{z^2}$
when z is on the real axis ...
$f(z) = \frac{(1 - e^{ix})}{x^2}$ where x is real
$f(z) = \frac{1 - (\cos(x)+i\sin(x))}{x^2}= \frac{1 - \cos(x)}{x^2}-i \frac{\sin(x)}{x^2}$
so the integral of $\frac{1 - \cos(x)}{x^2}$ is the real part of the integral of $f(z)$
A: 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.
A: Because on the real axis $y=0$ we have
$$\operatorname{Re} \left( \frac{1-e^{iz}}{z^2} \right) = \operatorname{Re} \left( \frac{1-e^{ix}}{x^2} \right) = \operatorname{Re} \left( \frac{1-\cos(x) - i \sin(x)}{x^2} \right) = \frac{1-\cos(x)}{x^2}.$$
