I have a question about an example in Stein/Shakarchi. Actually there is another thread here on SE Integrating $\int_0^\infty \frac{1-\cos x }{x^2}dx$ via contour integral.
Regarding the integral $\int_0^\infty \frac{1-\cos x }{x^2}dx$, I understand the indented semicircle contour, the division into 4 integrals, I also understand it until letting $R \rightarrow \infty$ and then applying ML estimation. However afterwards, I can not follow it anymore, where did the integrals of the two horizontal lines go? Do they cancel each other out (if yes, how can I see it?) and why do they write $f(z)$ as $f(z)=\frac{-i z}{z^2} + E(z)$ ? It would be really kind if someone could explain these last steps to me