if $f$ is such that : $\int_{-\infty}^{\infty} x^2f(x) \mathrm{d}x \leq M$ then $f = O(x^3)$ I am wondering if the following is true :

Let $f$ be a positive piecewise continuous function such that : $$\int_{-\infty}^{\infty} x^2f(x) \mathrm{d}x \leq M$$
  Then can we conclude that $f = O(x^{-3})$ at $\pm \infty$ ? 

I tried to see if a proof by contradiction works here yet what I am doing doesn't lead anywhere : 
Suppose there is a stricly increasing sequence $(x_n)$ such that : $f(x_n) \geq \frac{1}{x_n^2}$. But then what to do ? Since we can just say this on single point it's impossible to integrate (since it's discrete)..
Thank you ! 
 A: The answer is no. 
Let $f(x)=1/n^2$ in $[n,n+1/n^a]$ for $n\in\mathbb{N}^+$ and zero  otherwise then 
$$\int_{-\infty}^{\infty} x^2f(x)\,dx =\sum_{n=1}^{\infty} \frac{1}{n^2}\int_n^{n+1/n^a}x^2dx=\frac{1}{3}\sum_{n=1}^{\infty} \frac{1}{n^2} ((n+1/n^a)^3-n^3)\\
=\frac{1}{3}\sum_{n=1}^{\infty} \frac{1}{n^2}\cdot 
\left(\frac{3n^2}{n^a}+\frac{3n}{n^{2a}}+\frac{1}{n^{3a}}\right)$$
It follows that for  $a>1$ the RHS is convergent.
How can you modify $f$ in order to have a positive piecewise continuous function?
A: Define $f$ to be $0$ everywhere except that on $[n^{10},n^{10}+n^{-100}]$ it takes value $n^{40}$ (where $n\in \mathbb{N}$). This is piecewise constant, so in particular piecewise continuous, and we have 
$$
     \int_0^\infty x^2 f(x)\, dx < \sum_{n=1}^\infty (n^{10}+n^{-100})^2 n^{-60} < 1.
$$
However if $x=n^{10}$ then $f(x) = n^{40}$, which is not bounded by a constant times $x^3 = n^{30}$. 
A: If you assume that $f\in C^1$ and that $$\int_{-\infty}^\infty |f'(y)|\, dy<\infty, $$ then it is almost true. Indeed, with these assumptions the limit 
$$
\lim_{|x|\to \infty} f(x) $$ 
must exist, and so the limit of $x^2f(x)$ exists also, perhaps infinite. However, for the integral 
$$
\int_{-\infty}^\infty x^2 f(x)\, dx $$ 
to be finite, it is necessary that 
$$ \lim_{|x|\to \infty} x^2 f(x)=0, $$ 
that is, $f(x)=o(|x|^{-2})$. (You wanted $f(x)=O(|x|^{-3})$ which is slightly more than this).
