Q:

Compute integral using Cauchy Principal Value

Using the Cauchy Principal Value, I need to compute the following integral 
$$\int_{-\infty}^\infty\frac{\cos(ax) - \cos(bx)}{x^2}dx$$
I have used the standard semi-circle contour with an indentation around the singularity at $x=0$. However integrating around the outer semicircle and smaller one around $0$, I find they have no contribution to the integral and the residue is also $0$. However I know the integral is not equal to $0$.
Where have I gone wrong? 

A:

The integral can be rewritten as a double integral
$$\int_{-\infty}^\infty \frac{\cos(ax)-\cos(bx)}{x^2}\:dx = \int_{-\infty}^\infty \int_a^b \frac{\sin(yx)}{x}\:dy\:dx$$
Swapping the order of integration gives us 
$$\int_a^b \int_{-\infty}^\infty \frac{\sin z}{z} \:dz \:dy = \int_a^b \pi \:dy = \pi(b-a)$$
by using the substitution $z = yx$ on the inside.  The sinc integral can be done by considering a rectangular contour instead of a semicircle.  This insight means you could use a rectangular contour for the original integral if you wish. 

A:

Consider the contour of a semi-circle that avoids the singularity at $(0,0)$ of radius $\varepsilon$.  Notice the line integral of the arc of radius $\lim_{R \to \infty} R$ equals 0 from Jordan's lemma.   Also, consider $\cos{x}=\Re{\left(e^{ix}\right)}$, so we will take the real part of the integral.   By Cauchy's 1st theorem you're left with:
$$I=\int_{-\infty}^{\infty}\frac{\cos{ax}-\cos{bx}}{x^2} \; dx =-\int_{\pi}^0 \frac{e^{ia \varepsilon e^{i \theta}}-e^{ib \varepsilon e^{i \theta}}}{{\left(\varepsilon e^{i \theta}\right)}^2} \; i\varepsilon e^{i \theta} d\theta$$
Use the maclaurin series of $e^x$:
$$I=i\int_0^{\pi} \frac{ia \varepsilon e^{i \theta}-ib \varepsilon e^{i \theta}}{\varepsilon e^{i \theta}} \; d\theta$$
$$I=-\int_0^{\pi} {a -b } \; d\theta$$
$$I=\Re{\left(\pi \left(b-a\right)\right)}=\boxed{\pi \left(b-a\right)}$$

