How to evaluate the integral $\int_{0}^{\infty}\frac{\cos {(ax)}-\cos{(b x)}}{x^2 }dx$? I'm wondering how to integrate the so-called integral using Residue theorem,as it has a pole of second order on the real axis(not simple) so we cannot use $\pi i Res(@ z=0)$.Would you please give me a hint?($a,b>0$)
 A: Consider the integral
$$\oint_C dz \frac{e^{i a z}-e^{i b z}}{z^2} $$
where $C$ is a semicircle in the upper half plane of radius $R$ with a small semicircular detour at $z=0$ of radius $\epsilon$ into the upper half plane. Then the integral is equal to 
$$PV \int_{-R}^R dx \frac{e^{i a x}-e^{i b x}}{x^2} +i R \int_0^{\pi} d\theta \, e^{i \theta} \frac{e^{i a R e^{i \theta}} - e^{i b R e^{i \theta}}}{R^2 e^{i 2 \theta}} + i \epsilon \int_{\pi}^0 d\phi \, e^{i \phi} \frac{e^{i a \epsilon e^{i \phi}} - e^{i b \epsilon e^{i \phi}}}{\epsilon^2 e^{i 2 \phi}}$$
where $PV$ denotes the Cauchy principal value of the integral.  
As $R \to \infty$, the second integral vanishes.  This is so because the magnitude of the integral is bounded by
$$\frac1{R} \int_0^{\pi} d\theta  \, e^{-\min{(a,b)} R \sin{\theta} } \le \frac{2}{R} \int_0^{\pi/2} d\theta  \, e^{-2 \min{(a,b)} R \theta/\pi} \le \frac{\pi}{\min{(a,b)} R^2}$$
We now consider the third integral as $\epsilon \to 0$.  In this case, we Taylor expand the numerator and find that the integral has a limit:
$$i \epsilon \int_{\pi}^0 d\phi \, e^{i \phi} \frac{i a \epsilon e^{i \phi} - i \epsilon b e^{i \phi}}{\epsilon^2 e^{i 2 \phi}} = -\pi(b-a)$$
By Cauchy's theorem, the contour integral is zero.  Thus, in these limits - and taking the real part of both sides - we find that
$$\int_{-\infty}^{\infty} dx \frac{\cos{ax}-\cos{b x}}{x^2} = \pi (b-a) $$
or

$$\int_{0}^{\infty} dx \frac{\cos{ax}-\cos{b x}}{x^2} = \frac{\pi}{2} (b-a) $$

A: It can be seen as a limit case of Frullani's theorem, but it also follows from:
$$\int_{0}^{+\infty}\left(\frac{\sin x}{x}\right)^2\,dx \stackrel{i.b.p.}{=}\int_{0}^{+\infty}\frac{\sin(2x)}{x}\,dx=\frac{\pi}{2} $$
since:
$$ \int_{0}^{+\infty}\frac{1-\cos(ax)}{x^2}\,dx = 2\int_{0}^{+\infty}\left(\frac{\sin\frac{ax}{2}}{x}\right)^2\,dx. $$
A: Using the trigonometric identity in my comment above... Let $y=1/x$. Then $-dx/x^2=dy$ and we have
$$-\frac{1}{2}I=\int_0^{\infty}\sin\left(\frac{1}{2}(a+b)/y\right)\sin\left(\frac{1}{2}(a-b)/y\right)dy.$$
Mathematica gives the primitve to be, which can probably be obtained using i.b.p.,
$$-\frac{a \text{Si}\left(\frac{a}{y}\right)}{2}-\frac{1}{2} y \cos \left(\frac{a}{y}\right)+\frac{b \text{Si}\left(\frac{b}{y}\right)}{2}+\frac{1}{2} y \cos \left(\frac{b}{y}\right),$$
where $\text{Si}$ is the sine integral, which evaluates over the limits to be
$$I=\frac{\pi}{2}\left(\left|b\right|-\left|a\right|\right)$$
for all $a,b\in\mathbb{R}$.
Not a proof, but an alternative outline to the residue calculus perhaps.
A: By integration by part, we reduce the power 2. $$
\begin{aligned}
& \int_{0}^{\infty} \frac{\cos (a x)-\cos (b x)}{x^{2}} d x \\
=&-\int_{0}^{\infty}[\cos (a x)-\cos (b x)] d\left(\frac{1}{x}\right) \\
=&\left.-\left[\frac{\cos (a x)-\cos b x}{x}\right]_{0}^{\infty}+\int_{0}^{\infty} \frac{-a \sin (a x)+b \sin (b x)}{x}dx\right]\\=&-a \int_{0}^{\infty} \frac{\sin (a x)}{x} d x+b\int_{0}^{\infty} \frac{\sin (b x)}{x} d x
\end{aligned}
$$
Using the formula, $$
\int_{0}^{\infty} \frac{\sin (k x)}{x} d x=\frac{\pi}{2} \operatorname{sgn}(k),
$$
We can conclude that
$$
 \int_{0}^{\infty} \frac{\cos (a x)-\cos (b x)}{x^{2}} d x =\frac{\pi}{2}(|b|-|a|)
$$
