Complex Integral Question I'm trying to evaluate the following integral, in preparation for my exam tomorrow;
$$\int_{0}^{\infty} \frac{\cos(2x) - 1}{x^2} dx$$
However, I'm having a lot of issues with it. I was initially trying an argument involving $e^{2iz}$, but I can't seem to work in that constant.
I know that the contour I should be evaluating is going to be a half annulus, as the singularity occurs at $x = 0$, but I'm really just not sure what I'm aiming for here.
Anything to start me off would be fantastic, thank you!!
 A: There are of course many ways to evaluate the integral. If we're using $e^{2iz}$ and the boundary of a half-annulus as the contour, we should use the parity of the integrand and start with
$$\begin{align}
\int_0^\infty \frac{\cos (2x)-1}{x^2}\,dx &= \frac{1}{2} \int_{-\infty}^\infty \frac{\cos (2x)-1}{x^2}\,dx\\
&= \frac{1}{2}\lim_{\substack{\varepsilon\to 0\\ R\to\infty}} \left(\int_{-R}^{-\varepsilon}\frac{\cos (2x)-1}{x^2}\,dx + \int_\varepsilon^R \frac{\cos (2x) - 1}{x^2}\,dx\right)\\
&= \frac{1}{2}\lim_{\substack{\varepsilon\to 0\\ R\to\infty}} \left(\int_{-R}^{-\varepsilon}\frac{e^{2ix}-1}{x^2}\,dx + \int_\varepsilon^R \frac{e^{2ix} - 1}{x^2}\,dx\right),
\end{align}$$
where the last equality is due to the oddness of $\sin$. Now writing $s_r$ for the semicircle of radius $r$, $s_r(t) = re^{it}, 0\leqslant t \leqslant \pi$, Cauchy's integral theorem says
$$\int_{-R}^{-\varepsilon}\frac{e^{2iz}-1}{z^2}\,dz + \int_{\varepsilon}^R \frac{e^{2iz}-1}{z^2}\,dz + \int_{S_R}\frac{e^{2iz}-1}{z^2}\,dz - \int_{s_\varepsilon}\frac{e^{2iz}-1}{z^2}\,dz = 0.$$
In the upper half-plane, we have $\lvert e^{2iz}\rvert = e^{-2\operatorname{Im} z} \leqslant 1$, so $\left\lvert \frac{e^{2iz}-1}{z^2}\right\rvert \leqslant \frac{2}{R^2}$ on $s_R$, and the integral over $s_R$ tends to $0$ as $R\to \infty$. Therefore
$$\begin{align}
\lim_{\substack{\varepsilon\to 0\\ R\to\infty}} \left(\int_{-R}^{-\varepsilon}\frac{e^{2ix}-1}{x^2}\,dx + \int_\varepsilon^R \frac{e^{2ix} - 1}{x^2}\,dx\right)
&= \lim_{\varepsilon\to 0} \int_{s_\varepsilon} \frac{e^{2iz}-1}{z^2}\,dz - \lim_{R\to\infty} \int_{s_R}\frac{e^{2iz}-1}{z^2}\,dz\\
&= \lim_{\varepsilon\to 0} \int_{s_\varepsilon} \frac{e^{2iz}-1}{z^2}\,dz.
\end{align}$$
Since $\frac{e^{2iz}-1}{z^2}$ has a simple pole in $0$, we have
$$\lim_{\varepsilon\to 0} \int_{s_\varepsilon} \frac{e^{2iz}-1}{z^2}\,dz = \pi i \operatorname{Res}\left(\frac{e^{2iz}-1}{z^2}; 0\right) = \pi i(2i) = -2\pi,$$
as can be read off the Taylor series of $e^{2iz}$. Thus
$$\int_0^\infty \frac{\cos (2x)-1}{x^2}\,dx = -\pi.$$

Another way to evaluate the integral uses the trigonometric identity $\cos (2x) - 1 = - 2\sin^2 x$, which then yields
$$\int_0^\infty \frac{\cos (2x)-1}{x^2}\,dx = -2\int_0^\infty \frac{\sin^2 x}{x^2}\,dx.$$
We can now for example integrate by parts,
$$\begin{align}
\int_0^\infty \frac{\sin^2 x}{x^2}\,dx &= \left[-\frac{\sin^2 x}{x}\right]_0^\infty + \int_0^\infty \frac{2\sin x\cos x}{x}\,dx\\
&= \int_0^\infty \frac{\sin (2x)}{x}\,dx\\
&= \int_0^\infty \frac{\sin t}{t}\,dt, \tag{$t = 2x$}
\end{align}$$
and evaluate that integral also via the residue theorem (or with whatever one's favourite method is).
Instead of integrating by parts, we could also have noted that
$$\int_{-1}^1 e^{-ix\xi}\,d\xi = \left[-\frac{e^{-ix\xi}}{ix}\right]_{-1}^1 = \frac{e^{ix} - e^{-ix}}{ix} = 2\frac{\sin x}{x},$$
so $\frac{\sin x}{x}$ is the Fourier transform of $\sqrt{\frac{\pi}{2}}\cdot \chi_{[-1,1]}$, and Plancherel's theorem together with the parity of the integrand gives us
$$2\int_0^\infty \frac{\sin^2 x}{x^2}\,dx = \int_{-\infty}^\infty \frac{\sin^2 x}{x^2}\,dx = \frac{\pi}{2} \int_{-\infty}^\infty \chi_{[-1,1]}(x)^2\,dx = \pi.$$
