Find $\int_{0}^{\infty }\frac{\cos x-\cos x^2}{x}\mathrm dx$

Because $\displaystyle \int_{0}^{\infty }\frac{\cos x}{x}\, \mathrm{d}x$ does not converge, you can see here for a proof.

So we have to find another way to evaluate it.

I'll think about it and post a solution later.


Solution: \begin{align*} \int_{0}^{\infty }\frac{\cos x-\cos x^2}{x}\,\mathrm{d}x&=\lim_{\alpha \rightarrow \infty }\int_{0}^{\alpha }\frac{\cos x-\cos x^2}{x}\,\mathrm{d}x=\lim_{\alpha \rightarrow \infty }-\int_{0}^{\alpha }\frac{1-\cos x+\cos x^2-1}{x}\,\mathrm{d}x\\ &=\lim_{\alpha \rightarrow \infty }\left ( -\int_{0}^{\alpha }\frac{1-\cos x}{x}\,\mathrm{d}x+\int_{0}^{\alpha }\frac{1-\cos x^2}{x}\,\mathrm{d}x \right )\\ &=\lim_{\alpha \rightarrow \infty }\left ( -\int_{0}^{\alpha }\frac{1-\cos x}{x}\,\mathrm{d}x+\frac{1}{2}\int_{0}^{\alpha^{2} }\frac{1-\cos x}{x}\,\mathrm{d}x \right )\\ &=\lim_{\alpha \rightarrow \infty }\left \{ \mathrm{Ci}\left ( \alpha \right )-\gamma -\ln\alpha +\frac{1}{2}\left [ \gamma +\ln\alpha ^{2}-\mathrm{Ci}\left ( \alpha ^{2} \right ) \right ] \right \}\\ &=\lim_{\alpha \rightarrow \infty }\left [ -\frac{\gamma }{2}+\mathrm{Ci}\left ( \alpha \right )-\frac{1}{2}\mathrm{Ci}\left ( \alpha ^{2} \right ) \right ]\\ &=-\frac{\gamma }{2} \end{align*} where $\mathrm{Ci}\left ( \cdot \right )$ is Cosine Integral and we can easily find that $\mathrm{Ci}\left ( \alpha \right )$ goes to $0$ when $\alpha \rightarrow \infty $.


We begin by noting that we can write the integral of interest as

$$\begin{align} \int_0^\infty \frac{\cos(x)-\cos(x^2)}{x}\,dx&=\int_0^\infty \frac{e^{ix}-e^{ix^2}}{x}\,dx-i\int_0^\infty\frac{\sin(x)-\sin(x^2)}{x}\,dx\\\\ &=\int_0^\infty \frac{e^{ix}-e^{ix^2}}{x}\,dx-i\pi/4 \tag 1 \end{align}$$

Using Cauchy's Integral Theorem, we can write the right-hand side of $(1)$ as

$$\int_0^\infty \frac{e^{ix}-e^{ix^2}}{x}\,dx-i\pi/4 =\int_0^\infty \frac{e^{-x}-e^{-x^2}}{x}\,dx \tag 2$$

Integrating by parts the integral on the right-hand side of $(2)$ with $u=e^{-x}-e^{-x^2}$ and $v=\log(x)$ reveals

$$\begin{align} \int_0^\infty \frac{e^{-x}-e^{-x^2}}{x}\,dx &=\int_0^\infty \log(x) e^{-x}\,dx-\int_0^\infty 2x\log(x)e^{-x^2}\,dx\\\\ &=\frac12 \int_0^\infty e^{-x}\log(x)\,dx\\\\ &=-\frac12\gamma \end{align}$$

And we are done!


NOTE:

In the note at the end of THIS ANSWER, I showed that $\gamma$ as given by $\gamma=-\int_0^\infty e^{-x}\,\log(x)\,dx$ is equal to $\gamma$ as expressed by the limit $\gamma=\lim_{n\to \infty}\left(-\log(n)+\sum_{k=1}^n\frac1k\right)$.