evaluate $\int _0 ^\infty \frac{1-\cos(ax)}{x^2}dx$ Im trying to evaluate for a given $a\in \mathbb R$$$\int _0 ^\infty \frac{1-\cos(ax)}{x^2}dx$$
I have noticed that since $1-\cos(ax)$ is analytic in $\mathbb C$, the integral $$\int _{C}  \frac{1-\cos(az)}{z^2}dz$$where $C$ is a simple closed contour around the point $z_0=0$, is by Cauchy's integral formula: $$(1-\cos(az_0))'=a\sin(az_0)=0$$which might hint that the solution lays within integration of half a circle in the positive (or negative) imaginary plane. I also think that since the function inside the integral is even, it is tempting to try and evaluate the real integral from $-\infty$ to $\infty$, and correspondingly evaluate the complex integral for bigger contours.
 A: Perhaps the following helps. Assume $\;a>0\;$ and define :
$$I(a):=\int_0^\infty\frac{1-\cos ax}{x^2}dx\implies I'(a)=\int_0^\infty\frac{\sin ax}x=\frac\pi2\implies I(a)=\frac{\pi a}2$$
With complex analysis: for very small real $\;\epsilon>0\;$ :
$$C_{\epsilon,R}:=[-R,-\epsilon]\cup\gamma_\epsilon=\{\epsilon e^{it}\;:\;\;0\le t<\pi\;\}\cup[\epsilon, R]\cup\gamma_R:=\{Re^{it}\;,\;\;0\le t<\pi\}\;,\;\;R\in\Bbb R^+$$
Define also
$$f(z)=\frac{1-e^{iaz}}{z^2}$$
then, as $\;f\;$ is analytic on and within $\;C_{\epsilon,R}\;$ , we get
$$\oint_{C_{\epsilon,R}}f(z)\,dz=0$$
Yet,  as the function has a simple pole (check this) at $\;z=0\;$, and
$$\text{Res}_{z=0}(f)=\lim_{z\to0}\,(z\,f(z))\stackrel{\text{l'H}}=-ia$$
we can use this to obtain
$$\lim_{\epsilon\to0}\int_{\gamma_\epsilon}f(z)\,dz=-\pi i(ia)=\pi a$$
and also
$$\left|\int_{\gamma_R}f(z)\,dz\right|\le\pi R\max_{0\le t<\pi}\frac{1+e^{-aR\sin t}}{R^2}\xrightarrow[R\to\infty]{}0$$
so
$$0=\oint_{C_{\epsilon,R}}f(z)\,dz=\int_{-R}^{-\epsilon}\frac{1-e^{iax}}{x^2}dx+\int_{\gamma_\epsilon}f(z)\,dz+\int_\epsilon^R\frac{1-e^{iax}}{x^2}dx+\int_{\gamma_R}f(z)\,dz$$
$$\xrightarrow[\epsilon\to0,\,R\to\infty]{}\int_{-\infty}^0\frac{1-\cos ax-i\sin ax}{x^2}-\pi ia+\int_0^\infty\frac{1-e^{iax}}{x^2}dx +0\implies$$
$$\int_{-\infty}^\infty\frac{1-\cos ax-i\sin ax}{x^2}dx=\pi a$$
and comparing real parts and dividing by two (even function)::
$$\int_0^\infty\frac{1-\cos ax}{x^2}=\frac{\pi a}2$$
If $\;a<0\;$ something very similar (in fact, I'd say identical) is done above, so the result for general 
$\;a\;$ should, in my opinion, be $\;\frac{\pi |a|}2\;$, but I'm not quite sure so you better check this.
