Do integrable functions vanish at infinity? [duplicate]
If $f$ is a real-valued function that is integrable over $\mathbb{R}$, does it imply that
$$f(x) \to 0 \text{ as } |x| \to \infty? $$
When I consider, for simplicity, positive function $f$ which is integrable, it seems to me that the finiteness of the "the area under the curve" over the whole line implies that $f$ must decay eventually. But is it true for general integrable functions?
HINT Consider the function $f:\mathbb R\to\mathbb R$ which is zero for negative numbers, and for each natural number $n$, $f(x)=n$ for $x\in\left[n,n+\frac{1}{n^3}\right]$ and $f(x)=0$ for $x\in\left(n+\frac{1}{n^3},n+1\right)$.
You need some stronger conditions on $f$ than just measurability.
Here is a beautiful counter-example:
$$\int_{\mathbb R}\sin(x^2)\ dx=\sqrt{\frac\pi2}$$
Other more extreme examples
$$\int_{\mathbb R}x\sin(2^{|x|})\ dx$$
These rely on the Dirichlet test for convergence of a series/integral.
There are already good answers, I only wanted to make it more visual. Observe that
\begin{align} \infty &< \sum_{k=0}^{\infty} k\ \cdot\ \ \ 2^{-k}\ \ =\hspace{10pt}2 < \infty \\ \infty &< \sum_{k=0}^{\infty} k\cdot(-2)^{-k} =-\frac{2}{9} < \infty \end{align}
(it's easy enough to do by hand, but if you want, here and here are links to WolframAlpha).
Thus, we can use:
$$ f(x) = \sum_{k = 0}^{\infty}k\cdot(-1)^k \cdot \max(0,1-2^k\cdot|x-k|) $$
Below are diagrams for $|f|$ and $f$:
I hope this helps $\ddot\smile$
No, a classic example is the Fresnel's Integral (in fact the integrand is analytic and not just integrable) $$\int_0^{\infty} \cos(x^2)dx = \int_0^{\infty} \sin(x^2)dx = \sqrt{\dfrac{\pi}8}$$