How to prove that the integral $$\int_{0}^{\infty}\frac{\cos x}{x}dx$$ diverges (I'm looking for an elegant argument, preferably without deriving Euler-Mascheroni constant and all that).
A (not so elegant) attempt Pick a positive number $a< \frac{\pi}{2}$. Since $\cos x$ is a decreasing function for $x \in [0,a]$ then $\cos a \leq \cos x$ and in particular $$\cos a \int_0^{a}\frac{1}{x}dx \leq \int_0^{a}\frac{\cos x}{x}dx$$ Since the first integral diverges to $+\infty$, so does the second. And it suffice now to show that the integral for $[a, \infty)$ is either finite or diverges to positive infinity.
For $x \in [a, \frac{3}{2}\pi]$, we have $\frac{\cos x}{x} < \frac{1}{x} < \frac{1}{a}$ and the integral is bounded above by $\frac{3/2\pi - a}{a}$ (A similar argument for below). Finally, for all integers $k>0$, note that $\cos x \geq 0$ for $x \in [\frac{4k-1}{2}\pi, \frac{4k+1}{2}\pi]$ and $\cos x = -\cos (x-\pi)$. Then
$$\begin{align}{\large\int}_{\frac{4k-1}{2}\pi}^{\frac{4k+1}{2}\pi}\frac{\cos x}{x}dx + {\large\int}_{\frac{4k+1}{2}\pi}^{\frac{4k+3}{2}\pi}\frac{\cos x}{x}dx &= {\large\int}_{\frac{4k-1}{2}\pi}^{\frac{4k+1}{2}\pi}\frac{\cos x}{x} - \frac{\cos x}{x+\pi}dx \\&={\large\int}_{\frac{4k-1}{2}\pi}^{\frac{4k+1}{2}\pi}\frac{\pi \cos x}{x(x+\pi)}dx \end{align}$$ the integral is non-negative since the integrand is non-negative in the interval.