Question about evaluating the integral $\int_0^\infty \frac{1-\cos(ax)}{x^2}dx$ using the residue theorem Question: Evaluate the integral
$$\int_0^\infty \frac{1-\cos(ax)}{x^2}dx$$
where $a \in R$.
My attempt: So, I actually have a worked out solution for this, but I'm confused on a few points and I'm hoping to get some help. The solution considers the function
$$f(z) = \frac{1-e^{i|a|z}}{z^2},$$
and evaluates it around the contour $\Gamma = C_R \cup [-R,-\epsilon] \cup C_\epsilon \cup [\epsilon,R]$, for $R$ large, $\epsilon$ small, $C_R$ the semicircle in the upper half plane of radius $R$, and $C_\epsilon$ the semicircle in the upper half plane of radius $\epsilon$ but with negative orientation.
The next step they do is show that $|f(z)|$ on $C_R$ goes to $0$ as $R \to \infty$. I think that I understand this part, but I'm not 100% sure, so I'd just like to check:
$$\left|\frac{1-e^{i|a|z}}{z^2}\right| \le \frac{|1-e^{i|a|R\cos\theta} - e^{i|a|R\sin\theta}|}{R^2}\le \frac{2+|e^{-|a|R\sin\theta}}{R^2},$$
and the RHS of the above goes to $0$ as $R \to \infty$. So, first question: 1) is my above reasoning correct? In the solution, they have a $1 + |e^{-|a|R\sin\theta}$ as the numerator in the last term, but I'm not sure how to get that stronger bound, so I'm unsure if my weaker one is correct.
Ok, so after this they write: 
$$\int_0^\infty \frac{1-\cos(ax)}{x^2}dx = \frac{1}{2}\Re\left(\pi i \cdot \text{res}_{0}f(z)\right)$$
$=\frac{\pi |a|}{2}.$$
This is the step that is driving me a little insane. I guess I must be missing something. So, I have a few questions here:
2) First of all, what I think they are saying is that
$$\int_\Gamma f(z)dz = \int_{C_R}f(z)dz + 2\int_{\epsilon}^{R}f(z)dz + \int_{C_\epsilon}f(z)dz,$$
and then taking limits as $\epsilon \to 0$, and $R \to \infty$. But what happens to the integral over $C_\epsilon$??? 
3) I guess maybe they are saying that as $\epsilon \to 0$, the integral over $C_\epsilon$ approaches the residue at $0$. But I don't understand why that's valid - why are we allowed to use the residue theorem on this integral? It's not even a contour, it doesn't have an interior, and I guess I'm just very confused here.
Thanks!
 A: The integral over $C_{\epsilon}$ can be written
$$\int_{C_{\epsilon}} \frac{1-e^{i|a|z}}{z^2}\,dz=-\int_0^{\pi}\frac{1-e^{i|a|\epsilon e^{i\phi}}}{\epsilon^2 e^{i2\phi}} \,i\epsilon e^{i\phi}\,d\phi \tag1$$
Noting that $e^{i|a|\epsilon e^{i\phi}}-1=i|a|\epsilon e^{i\phi}+O(\epsilon^2)$, the limit as $\epsilon \to 0$ of the integral on the right-hand side of $(1)$ is simply $-\pi|a|$.

Finally, note that this result is one half of $2\pi i \text{Res}\left( \frac{1-e^{i|a|z}}{z^2},z=0\right)$, where the factor of $1/2$ is a consequence of integration over a semi-circle rather than the closed circular contour.

A: $$\int_0^\infty \frac{1-\cos(ax)}{x^2}dx  =-\int_0^\infty \left(\frac{1}{x}\right)'(1-\cos(ax))dx \\=-\left[ \frac{1-\cos(ax)}{x}\right]^\infty_0 +a\int_0^\infty\frac{\sin(ax)}{x}dx = a\int_0^\infty\frac{\sin(ax)}{x}dx =\color{red}{sign(a)\frac{\pi a}{2}}$$ Given that: 
$$\lim_{x\to 0} \frac{1-\cos(ax)}{x} = \lim_{x\to 0} a^2x\frac{1-\cos(ax)}{(ax)^2} =0*\frac12 =0.$$
and $$ \int_0^\infty\frac{\sin(ax)}{x}dx  =\overset{u=ax}{=}sign(a)\int_0^\infty\frac{\sin(x)}{x}dx $$
