Could you tell me how to solve this integral?
$$\int_0^{\infty} \frac{\cos x -1}{x^2}dx$$
I think I should focus on this integral $$\int_{\Gamma} \frac{e^{iz}-1}{z^2+ \varepsilon^2}$$
where $\Gamma$ is a curve = semicircle with radius $R \cup $ segment $[-R, R]$
The integral vanishes on the semicircle.
The poles of $\frac{e^{iz}-1}{z^2+ \varepsilon^2}$ are $\varepsilon i, - \varepsilon i$.
So $$\int_{\Gamma} \frac{e^{iz}-1}{z^2+ \varepsilon^2} = 2 \pi i \cdot res_{\varepsilon i} \left(\frac{e^{iz}-1}{z^2+ \varepsilon}\right) = 2 \pi i \frac{e^{- \varepsilon}-1}{2 \varepsilon i} = \frac{\pi (e^{- \varepsilon}-1)}{\varepsilon}$$
We have $\frac{0}{0}$ situation, so we can use de l'Hospital theorem:
$$\lim_{\varepsilon \rightarrow 0} \frac{\pi (e^{- \varepsilon}-1)}{\varepsilon} = \lim _{\epsilon \rightarrow 0}\pi \frac{- \varepsilon e^{- \varepsilon}}{1}$$
But the answer is $\frac{- \pi}{2}$
Could you tell me what I'm doing wrong?