# $\int_0^\infty \frac{1-\cos(x)}{x^2}$.

I want to find $$\int_0^\infty \frac{1-\cos(x)}{x^2}dx$$ The integrand is continuous at $$0$$, so $$f(z):=\frac{1-\cos(z)}{z^2}$$ is entire. By the Residue Theorem, $$0=\int_{C_R} f(z)dz+\int_{-R}^R f(z)dz,$$ where $$C_R$$ is the semicircular contour of radius $$R$$ centered at $$0$$ in the upper half-plane (oriented counterclockwise). Now $$\int_{C_R}f(z)dz= \int_0^\pi \frac{1-\cos(Re^{i\theta})}{R^2e^{i2\theta}}Rie^{i\theta}d\theta=\int_0^\pi \frac{1-\cos(Re^{i\theta})}{R}ie^{-i\theta}d\theta,$$ which does not seem easily manageable.

Differentiating under the integral sign works naively, by letting $$I(a):=\int_0^\infty \frac{1-\cos(ax)}{x^2}dx$$ then $$I'(a)=\frac{\pi}{2}$$ and $$I(0)=0$$. The issue is that the derivative of the integrand is not integrable, so the passage of the limit into the integral is not legitimate.

$$\frac{1-e^{iz}}{z^2}$$