What's an easy example of a function $f$ such that
$$\int_1^{\infty}f(x)dx$$ converges, but not absolutely?
What's an easy example of a function $f$ such that
$$\int_1^{\infty}f(x)dx$$ converges, but not absolutely?
On
The simplest example that comes to my mind is
\begin{equation*}
\int\limits_{1}^\infty \frac{\sin(x)}{x}\, dx \,=\, 0.624713\ldots~.
\end{equation*}
Even nicer is
\begin{equation*}
I \,:=\,
\int\limits_{0}^\infty \frac{\sin(x)}{x}\, dx \,=\, \frac{\pi}{2}~. \tag{1}
\end{equation*}
(The lower bound is immaterial when the question is about absolute/conditional convergence of
an integral with the upper bound at $+\infty$, as long as the function under the integral is continuous.)
The following is the answer to another question by "mavavilj", in the comment to the answer (above) to the original question:
How to see the convergence, but not absolute convergence of these?
(A) $~$The integral $(1)$ is not absolutely convergent: \begin{equation*} \int\limits_{k\pi}^{(k+1)\pi} \frac{|\sin(x)|}{|x|}\,dx \,\geq\, \int\limits_{k\pi}^{(k+1)\pi} \frac{|\sin(x)|}{(k\!+\!1)\pi}\,dx \,=\, \frac{1}{(k\!+\!1)\pi}\int\limits_0^\pi\sin(x)\,dx \,=\,\frac{2}{(k\!+\!1)\pi}~, \end{equation*} and the series $\sum_{k=0}^\infty 1/(k\!+\!1)$ diverges.
(B) $~$The integral $(1)$ converges (conditionally). We introduce the integrals with a finite positive upper bound $A$:
\begin{equation*}
I_A \,:=\, \int\limits_0^A \frac{\sin(x)}{x}\,dx~, \qquad
J_A \,:=\, \int\limits_0^A \frac{\sin^2(x)}{x^2}\,dx~.
\end{equation*}
Note that $J$, the integral $J_A$ with the upper bound $\infty$ instead of $A$,
converges absolutely, because the (positive) value of the integrand is $\leq 1/x^2$ (which is of interest to us only for large enough $x$,
say for $x\geq 1$). Now we compute $J_A$ per partes:
\begin{align*}
J_A &\,=\, \int\limits_0^A \sin^2(x)\left(\!\frac{-1}{x}\!\right)'dx \\
&\,=\, \biggl(\!-\,\frac{\sin^2(x)}{x}\,\Biggr|_0^A
\,+\, \int\limits_0^A\frac{2\sin(x)\cos(x)}{x}\,dx \\
&\,=\, -\,\frac{\sin^2(A)}{A} \,+\, \int\limits_0^A\frac{\sin(2x)}{2x}\,d(2x) \\
&\,=\, -\,\frac{\sin^2(A)}{A} \,+\, \int\limits_0^{2A}\frac{\sin(x)}{x}\,dx \\
&\,=\, -\,\frac{\sin^2(A)}{A} \,+\, I_{2A}~,
\end{align*}
that is, writing $B:=2A$,
\begin{equation*}
I_B \,=\, J_{B/2} \,+\, \frac{\sin^2(B/2)}{B/2}~, \qquad \text{for all $B>0$}\,.
\end{equation*}
We see that $I_B$ converges to $I=I_\infty=J_\infty=J$ as $B\to+\infty$.
Quite unintentionally (indeed$\ldots$)
we obtained the bonus result $I=J$.
Also $$\int_1^\infty \frac{\sin(x-1)}{x-1}\mathrm d x,$$ work.