TITLE: Find $\int_{0}^{\infty }\frac{\cos x-\cos x^2}{x}\mathrm dx$
QUESTION [10 upvotes]: Recently, I met a integration below
\begin{align*}
\int_{0}^{\infty }\frac{\sin x-\sin x^2}{x}\mathrm{d}x&=\int_{0}^{\infty }\frac{\sin x}{x}\mathrm{d}x-\int_{0}^{\infty }\frac{\sin x^{2}}{x}\mathrm{d}x\\
&=\int_{0}^{\infty }\frac{\sin x}{x}\mathrm{d}x-\frac{1}{2}\int_{0}^{\infty }\frac{\sin x}{x}\mathrm{d}x\\
&=\frac{1}{2}\int_{0}^{\infty }\frac{\sin x}{x}\mathrm{d}x=\frac{\pi }{4}
\end{align*}
the same way seems doesn't work in
$$\int_{0}^{\infty }\frac{\cos x-\cos x^2}{x}\mathrm dx$$
but why? Then how to evaluate it? Thx!

REPLY [7 votes]: 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)$.



EDIT:  A SECOND METHODOLOGY:
It is straightforward to show that for $t>0$
$$\int_0^\infty \frac{\cos(x^t)-e^{-x^t}}{x}\,dx=0\tag3$$
Simply enforce the substitution $x^t\mapsto x$ to reduce the integral in $(3)$ to
$$\int_0^\infty \frac{\cos(x^t)-e^{-x^t}}{x}\,dx=\frac1t \int_0^\infty \frac{\cos(x)-e^{-x}}{x}\,dx$$
Then, exploiting a property of the Laplace Transform, we can write
$$\int_0^\infty \frac{\cos(x)-e^{-x}}{x}\,dx=\int_0^\infty \left(\frac{x}{x^2+1}-\frac{1}{x+1}\right)\,dx$$
which is easily evaluated as $0$.
Hence, we can write
$$\int_0^\infty \frac{\cos(x^2)-\cos(x)}{x}\,dx=\int_0^\infty \frac{e^{-x^2}-e^{-x}}{x}\,dx\tag4$$
The integral on the the right-hand side of $(4)$ is identical to the integral on the the right-hand side of $(2)$, from which we obtain the previous result!