Construct a continuous function such that $\int_{-\infty}^\infty|f(x)|\,dx<\infty$ but $\lim_{x\to \infty}|f(x)|$ does not exists. I have to construct a continuous function such that
$$\int_{-\infty}^\infty |f(x)| \, dx<\infty$$
but
$$\lim_{x\to \infty}|f(x)|$$
does not exists.
I have already known one messy example that deals with lines and minimum distance. I just want to see different examples. I know we can construct a triangle with fixed height and decreasing base such that the area get's smaller and the integral is like the geometric series. However, the fixed height makes the limit inexistent. I just dont know how to describe that properly.  Thanks.
 A: Hint:
$$ f(x) = \sum_{n\in\mathbb{Z}} n \exp\left[-n^6(x-n)^2\right] $$
does the job. Can you prove it?
A: Define:


*

*$f(x)=0$ when $x<0$.

*In $[0,1]$, the graph of $f$ is a line segment from $(0,0)$ to
$\left(\frac12,1\right)$ and a line segment from
$\left(\frac12,1\right)$ to $(1,0)$.

*In $[1,2]$, the graph of $f$ is a line segment from $(1,0)$ to $\left(1+\frac14,1\right)$, a line segment from $\left(1+\frac14,1\right)$ to $\left(1+\frac12,0\right)$ and a line segment from $\left(1+\frac12,0\right)$ to $(2,0)$.

*In $[2,3]$, the graph of $f$ is a line segment from $(2,0)$ to $\left(2+\frac18,1\right)$, a line segment from $\left(2+\frac18,1\right)$ to $\left(2+\frac14,0\right)$ and a line segment from $\left(2+\frac14,0\right)$ to $(3,0)$.

*And so on...


I shorter way of defining $f$ is: $f(x)=0$ if $x<0$ or $x>\lfloor x\rfloor+2^{-\lfloor x\rfloor}$ and$$f(x)=1-2\left|2^{\lfloor x\rfloor}\bigl(x-\lfloor x\rfloor\bigr)-\frac12\right|=1-\left|2^{\lfloor x\rfloor+1}\bigl(x-\lfloor x\rfloor\bigr)-1\right|$$otherwise.
A: $$
\text{For } x>0 \text{ let } f(x) = \begin{cases} 1 & \text{if } n < x < n + \dfrac 1 {2^n} \text{ for } n = 1,2,3,\ldots, \\ 0 & \text{otherwise}. \end{cases}
$$
For $x<0,$ just make this an even function.
Then $\lim\limits_{x\,\to\,\infty} |f(x)| $ does not exist, but $\displaystyle\int_{-\infty}^\infty |f(x)|\,dx < \infty.$
PS: I notice that I neglected continuity. That is easily dealt with by making these pulses triangular rather than rectangular. Thus
$$
f(x) = \begin{cases} 2^n(x-n) & \text{if } n<x<n+\dfrac 1 {2^n} \\ 2^n(n+1-x) & \text{if } n+\dfrac 1 {2^n}, < x < n + \dfrac 2 {x^n},   \\ 0 & \text{otherwise}. \end{cases}
$$
