$\int_{-\infty}^\infty x^k f(x) \, dx = 0 \Longrightarrow f(x)=0$ In reply to a question I just pointed out that if
$$
\int_{-\infty}^\infty  x^k f(x) \, dx = 0
$$
for $k=0,1,2,\cdots$, then $f(x) = 0$. 
However, I'm not certain if my reasoning is correct, or if there is a better way to do it.
My reasoning was:
$$
e^{-2\pi i x \omega} = \sum_{n=0}^\infty \frac{(-2\pi i x \omega)^n}{n!}
=\sum_{n=0}^\infty \alpha_n x^n \omega^n
$$
So:
$$
\sum_{n=0}^\infty \alpha_n \omega^n \int_{-\infty}^\infty  x^n f(x) \, dx = 0
$$
$$
\int_{-\infty}^\infty e^{-2\pi i x \omega}  f(x) \, dx = 0
$$
$$
F(\omega) = 0 \Longrightarrow f(x)=0
$$
where $F(\omega)$ is the Fourier Transform of $f(x)$. 
Is this correct? Do we really need the full force of Fourier inversion theorem or is there a simpler way to do this. We can assume that $\int_{-\infty}^\infty |f(x)|$ is finite.
Edit We can also assume that $f(x)$ is such that $\int_{-\infty}^\infty  x^k f(x) \, dx=0$ makes sense for all $k\ge 0$; after all that's the starting point!
 A: No, the reasoning is not correct. At the very least you need some hypotheses on $f$. It looks like you're assuming $f$ is integrable, but that's not enough to justify your reasoning - the series for the exponential does not converge uniformly on the line.
In fact what you're trying to prove is false, even if you assume that $f$ is in the Schwarz space! (That is, $f$ is infinitely differentiable and every derivative dies faster than every $1/|x|^n$ at infinity.)
Say $\phi$ is an infinitely differentiable function on $\Bbb R$ with compact support, such that $\phi=0$ on $(-1,1)$. Let $f$ be the Fourier transform of $\phi$. Then $f$ is a Schwarz function, and since every derivative of $\phi$ vanishes at the origin it follows that $\int f(x) x^n=0$ for every $n$, but $f\ne0$.
Edit, inspired by Ian's answer and one of Daniel Fischer's comments: It's true if $f$ has compact support. So it should also be true if $f$ dies fast enough at infinity. And it is; for example if $|f(x)|\le e^{-\delta|x|}$ for some $\delta>0$ then the Fourier transform $\hat f$ is holomorphic in some strip containing the real axis; since every derivative of $\hat f$ vanishes at the origin this shows that $\hat f=0$, hence $f=0$.
A: The question is simpler on a bounded interval. Here if you assume $f \in L^2([a,b])$ then you can do the following argument:


*

*Polynomials are dense in the continuous functions in the uniform norm.

*Continuous functions are dense in $L^2([a,b])$ in the $L^2$ norm.

*Convergence in $L^\infty([a,b])$ implies convergence in $L^2([a,b])$.

*Hence polynomials are dense in $L^2([a,b])$ in its own norm. 

*$L^2([a,b])$ is a Hilbert space, and now $f$ is a vector in this Hilbert space which is orthogonal to a dense subset, so it must be zero.


When you look at an unbounded domain instead, a whole bunch of subtleties pop out, for instance because polynomials are no longer $L^2$ at all. So you have to be careful about what function space you are talking about...and as pointed out in David C. Ullrich's answer, even seemingly very nice function spaces can fail to have this property.
