Evaluate improper integral $(\cos(2x)-1)/x^2$ Consider the following improper integral:
\begin{equation}
\int_0^\infty \frac{\cos{2x}-1}{x^2}\;dx
\end{equation}
I would like to evaluate it via contour integration (the path is a semicircle in the upper plane), but i have some problems: first, the only singularity would be $z=0$, but it is only an apparent singularity so the residue is $0$. There are no other singularity of interest, so the integral should be zero... But it can't be zero, so?
 A: $$
\int_0^\infty\frac{\cos 2\,x-1}{x^2}\,dx=\frac12\,\int_{-\infty}^\infty\frac{\cos 2\,x-1}{x^2}\,dx=\frac12\,\int_{-\infty}^\infty\frac{\Re(e^{2ix}-1)}{x^2}\,dx.
$$
The key is the choice of function to integrate along a path. The function
$$
f(z)=\frac{e^{2iz}-1}{z^2}=\frac{2\,i}{z}-2-\frac{4\,i}{3}\,z+\cdots
$$
has a simple pole at $z=0$ with residue $2\,i$. Take $R>0$ large and $\epsilon>0$ small. Integrate along a path formed by the positively oriented semicircle of radius $R$  in the upper half plane ($C_R$), the interval $[-R,-\epsilon]$ ($C_\epsilon$), the semicircle of radius $\epsilon$ negatively oriented and the interval $[\epsilon,R]$ and take the limit as $R\to\infty$ and $\epsilon\to0$. The integral along the path is zero, $\lim_{R\to\infty}\int_{C_R}f(z)\,dz=0$, but $\lim_{R\to\infty}\int_{C_\epsilon}f(z)\,dz=?$.
A: It is much easier to use Laplace Transform to calculate this improper integral. Recall that if $F(s)$ is the Laplace Transform of $f(x)$, then
$$\mathcal{L}\big\{\frac{f(x)}{x}\big\}=\int_s^\infty F(u)du.$$
Let $f(x)=\cos 2x-1$; then $F(s)=\frac{s}{s^2+4}-\frac{1}{s}$. Thus
\begin{eqnarray*}
\mathcal{L}\big\{\frac{\cos 2x-1}{x}\big\}&=&\int_s^\infty\left(\frac{u}{u^2+4}-\frac{1}{u}\right)du\\
&=&\ln s-\frac{1}{2}\ln(s^2+4).
\end{eqnarray*}
Therefore
\begin{eqnarray*}
\mathcal{L}\big\{\frac{\cos 2x-1}{x^2}\big\}&=&\int_s^\infty\left(\ln u-\frac{1}{2}\ln(u^2+4)\right)du\\
&=&-\pi+2\arctan\frac{s}{2}-s\ln s+\frac{1}{2}\ln(s^2+4).
\end{eqnarray*}
So
$$\int_0^\infty\frac{\cos 2x-1}{x^2}dx=\lim_{s\to o^+}\left(-\pi+2\arctan\frac{s}{2}-s\ln s+\frac{1}{2}\ln(s^2+4)\right)=-\pi.$$
