TITLE: Function that decays faster than any polynomial, but not in the Schwartz space?
QUESTION [12 upvotes]: Motivated by the very restrictive condition imposed in the definition of the Schwartz space, I was wondering about the following question.

Is there a $C^\infty$ function that decays faster than any polynomial, but
  whose derivatives do not?

That is, we would like $|x^n f(x)|$ to be bounded for all $n$ and $x$, but for $|x^n f^{(k)}(x)|$ to be unbounded for all $n$ and $k>0$ as $x$ ranges over the reals. 
Unfortunately, I only really know one rapidly decaying function (the exponential), and it doesn't work here. Maybe if we tack on some oscillation, like $\sin(x^2)$, that would help?

REPLY [25 votes]: Consider $f(x)=e^{-x^2}\sin(e^{x^2})$. Then $f'(x)=-2xe^{-x^2}\sin(e^{x^2})+2x\cos(e^{x^2}).$