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

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!

• Not sure how to evaluate this analytically, but Wolfram Alpha gives the value $$\int_0^\infty\frac{\cos x-\cos x^2}{x}dx = -\frac{\gamma}{2}$$ where $\gamma$ is the Euler-Mascheroni constant.
– Tom
Jan 16 '17 at 4:05

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$.

• I have never heard about the cosine integral, but thx anyway, I'll try to understand it.
– user407289
Jan 16 '17 at 4:15
• @user407289 you're welcome! Jan 16 '17 at 4:16
• One may ask to show that $Ci(x)=\gamma+\log(x)+\int_0^\infty \frac{\cos(t)-1}{t}\,dt$. Do you have any ideas? I've posted a solution herein. Jan 16 '17 at 19:03

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!