# Integrable function which limit does not go to 0 for x to infinity

I want to find a function, such that the function shall be $$p$$-integrable in the sense of $$\int_{\mathbb{R}}|f(x)|^pdx<\infty$$ for any $$p\in[1,\infty)$$ and that this does NOT imply $$\lim_{x\to\infty}f(x)=0$$.

Now it's similar to the question here Continuous unbounded but integrable functions, but I'm not looking for a function which is unbounded in any point, just one which limit in infinity does not converge to $$0$$ or better say does not exist.

Does anyone know of any examples?

• Do you care if $f$ is continuous? – πr8 May 7 '17 at 10:37
• nope, it doesn't matter to me – N. Maks May 7 '17 at 10:39
• and do you mean Lebesgue or Riemann integable? – πr8 May 7 '17 at 10:39
• Let's take Lebesgue – N. Maks May 7 '17 at 10:41
• Sure, then take $f(x) = \exp(-|x|) + \mathbb{I}[x\in\mathbb{Q}]$. (Or, as one of the answers states, even just $f(x) = \mathbb{I}[x\in\mathbb{Q}]$ ). – πr8 May 7 '17 at 10:43

There are, of course, a lot of examples of $p$ integrable functions such that the limit at infinity does not exist. For example, one can take the characteristic function of $\mathbb{Q}$.
It should be noted, however, that there is no function such that $\lim_{x \rightarrow \infty} f(x)$ exists and is $\ne 0$.
Indeed, assume $\lim_{x \rightarrow \infty} f(x) = \alpha > 0$. Then, for every $\epsilon >0$, there exists $M>0$ such that $$f(x) > \alpha - \epsilon \qquad \text{for every } x > M.$$ If you take $\epsilon$ such that $\alpha - \epsilon >0$ than you have that $$\int_{\mathbb{R}} |f(x)|^p \, dx \ge \int_{\{x > M\}} (\alpha - \epsilon)^p \, dx= \infty.$$
A similar argument works for $\alpha < 0$.
Take $f$ to be a piecewise affine function. At each natural number $n$ the graph of $f$ is a triangle of height $1$ (so $f(n)=1$) and basis $\frac{1}{n^{2/p}}$ and $f$ is zero elsewhere. Then $\limsup_{x\to\infty}f(x)=1$ while $$\int_0^\infty |f(x)|^p\,dx=\sum_n \frac1{n^2}<\infty.$$
• when I replied $p\ge 1$ was not specified, so it could have been $p<1$. – Gio67 May 7 '17 at 17:12
• Sorry, I deleted my previous comment. There is a bigger problem: The base doesn't get raised to the $p$th power, $f$ does. – zhw. May 7 '17 at 17:15