TITLE: Square integrable function that doesn't go to zero?
QUESTION [8 upvotes]: I'm reading through some elementary quantum mechanics textbooks and a few authors mention that "there exist pathological functions that are square-integrable but do not go to zero at infinity." (Griffiths)
I am having trouble coming up with one, does anybody have an example?
The only one I can think of is the dirac distribution (which isn't even a function...):

REPLY [5 votes]: Along the lines of David Mitra's comment, try
$$f = \sum_{n=1}^\infty 1_{[n, n + 2^{-n}]}.$$
That is, $f(x) = 1$ if $x$ is in one of the intervals $[1,1+1/2], [2, 2+1/4], [3, 3+1/8], \dots$, and $f(x) = 0$ otherwise.  Clearly $f(x)$ does not approach 0 as $x \to \infty$, since for any $N$ there are $x \ge N$ with $f(x) = 1$ and other $x \ge N$ with $f(x) = 0$.  But on the other hand, it's easy to compute that $\int f^2 = \sum_{n=1}^\infty 2^{-n} = 1$.
With a little more work you can make this function continuous, or even $C^\infty$.