Evaluate $\int_{-\infty}^{\infty}\frac{1-\cos(x)}{x^2}e^{ikx}dx$ Firstly $1-\cos(x)=2\big(\frac{1}{2}(1-\cos(x))\big)=2\sin^2(\frac{x}{2})$.
Also $$\sin^2(\frac{x}{2})=\Big(\frac{e^{\frac{1}{2}ix}-e^{-\frac{1}{2}ix}}{2i}\Big)^2=\frac{1}{4}(2-e^{ix}-e^{-ix})$$.
So the integral becomes: $$\frac{1}{2}\int_{-\infty}^{\infty}\frac{(2-e^{ix}-e^{-ix})}{x^2}e^{ikx}dx=\frac{1}{2}\int_{-\infty}^{\infty}\frac{2e^{ikx}-e^{ix(k+1)}-e^{ix(k-1)}}{x^2}dx$$.
We can now consider separate cases of $k$.
When $k=0$, we get $$\frac{1}{2}\int_{-\infty}^{\infty}\frac{2-e^{ix}-e^{-ix}}{x^2}dx$$.
Now I am stuck. The problem now is that $\int_{-\infty}^{\infty}\frac{2}{x^2}dx$ is a divergent integral. And the same problem arises when $|k|=1$. Have I made an error somewhere?
Also the pole at $x=0$ is not simple - how could we use contour integration for a non-simple pole that lies on the real line (I've not seen this before)?
 A: You may use contour integration in the complex plane to evaluate integral.
You have written integral in the form
$$I(k)=\frac{1}{2}\int_{-\infty}^{\infty}\frac{2e^{ikx}-e^{ix(k+1)}-e^{ix(k-1)}}{x^2}dx$$
Now, you should consider 4 cases
a) $k>1$
b) $k<-1$
c) $k\in[0,1]$
d) $k\in[-1,0]$
We go to the complex plane and  use the contour (case a)

This includes $I(k)$, integral along a big half-circle of radius $R\to\infty$ counter clockwise and a small half-circle of radius $r\to 0$ around $x=0$ clockwise.
Integral around this contour $\oint{f}(x)dx=0$, because there are not poles inside the contour. On the other hand $\oint{f}(x)dx=I(k)+\int_R+\int_r=2\pi{i}Res{f}(x)\Rightarrow I(k)=-\int_R-\int_r$, if $Res{f}(x)=0$
Integral along a big half-circle $\to0$ at $R\to\infty$ due to Jordan lemma.
$I(k)=-\int_r =-\frac{1}{2}\int_r\frac{2e^{ikx}-e^{ix(k+1)}-e^{ix(k-1)}}{x^2}dx\Rightarrow$ $${I(k)}=-\frac{1}{2}\lim_{r\to0}\int_{\pi}^0\frac{2 \exp(ikr e^{it}) -\exp(i(k+1)re^{it})-\exp(i(k-1)re^{it})}{r^2e^{2it}}ire^{it}dt$$
Expanding exponent into a series $\,\exp(ire^{it})=1+ire^{it}-\frac{1}{2}r^2e^{2it}-\frac{i}{3!}r^3e^{3it}+...$
$${I(k)}=\frac{1}{2}\lim_{r\to0}\int_0^{\pi}\frac{2 ikr e^{it} -i(k+1)re^{it}-i(k-1)re^{it}}{r^2e^{2it}}ire^{it}dt=\frac{\pi{i}}{2}\Bigl(2ik-i(k+1)-i(k-1)\Bigr)=0$$
Exactly in the same way $I(k)=0$ in the case b) (the only point - we have to close the contour in the lower half-plane and integrate around the point $x=0$ in the positive direction - counter clockwise)
In the case c) we go clockwise around $x=0$, but close the contour in the upper half-plane for first two terms and in the lower half-plane - for the third term of the integrand. In this case for the third term we will also get a residual at $x=0$ (the pole is inside the closed contour).
$${I(k)}=\frac{1}{2}\lim_{r\to0}\int_0^{\pi}\frac{2 ikr e^{it} -i(k+1)re^{it}-i(k-1)re^{it}}{r^2e^{2it}}ire^{it}dt-\frac{1}{2}2\pi{i} Res\Bigl(-\frac{e^{ix(k-1)}}{x^2}\Bigr)|_{x=0}=\frac{\pi{i}}{2}\Bigl(2ik-i(k+1)-i(k-1)\Bigr)+\pi{i}i(k-1)=\pi(1-k)$$
In the same way we evaluate the integral in the case d)
$I(k)=0$ for $k<-1$ and $k>1$
$I(k)=\pi(1-k)$ for $k\in[0,1]$
$I(k)=\pi(1+k)$ for $k\in[-1,0]$
