TITLE: Slight generalization of an exercise in (blue) Rudin
QUESTION [9 upvotes]: Exercise 7.20 of blue Rudin (Principles of Mathematical Analysis), 3rd edition, says:
If $f$ is continuous on $[0,1]$ and if 
$$\int_0^1f(x)x^n\,dx = 0, (n=0,1,2,\ldots),$$
prove that $f(x)=0$ on $[0,1].$ 
One proof: Let $\{p_n\}$ be a sequence of polynomials uniformly approximating $f.$ Then $p_nf\rightarrow f^2$ uniformly too. Then
$$\lim_{n\to\infty}\int_0^1p_n(x)f(x)\,dx = 0 = \int_0^1f^2(x)\,dx,$$
since we can interchange the integral and the limit. Since $f^2$ is continuous, we have $f^2=0$ and thus $f=0$ too.
Now, my question is if we drop the assumption that $\int_0^1f(x)\,dx = 0,$ does the result still hold? Slightly rephrased,
If $f$ is continuous on $[0,1]$ and satisfies 
$$\int_0^1f(x)x^n\,dx = 0, (n=1,2,3,\ldots),$$
is $f=0$ on $[0,1]?$ 
If $f(0) = 0$ then this is true. In this case, extend $f$ to an odd function on $[-1,1].$ Take a sequence of polynomials $\{q_n\}$ uniformly approximating $f.$ Then the sequence 
$${\frac{q_n(x)-q_n(-x)}{2}}$$
is an approximation of $f$ without a constant term, and we can apply the same trick as above.
So,we only need to look at the case when $f(0)\neq 0.$ Does anyone know a proof, or have a counterexample to this generalized statement?

REPLY [8 votes]: Set $g(x) = x f(x)$.  Then by the original exercise, $g=0$.  So $f(x) = 0$ for all $x \ne 0$, and by continuity, $f(0)=0$ also.
By a similar argument, if $\int_0^1 f(x) x^n dx = 0$ for all sufficiently large $n$, we must have $f=0$.
Edit: For a more sophisticated statement, one can show that if $\mu$ is any finite Borel measure on $[0,1]$ which satisfies $\int x^n \,d\mu = 0$ for all sufficiently large $n$, then $\mu$ must be supported at $\{0\}$, i.e. must be a point mass.  (One way to show this is the Stone-Weierstrass theorem: the span of $\{x^n : n \ge N\}$ is a subalgebra which separates points, so its closure must be all the continuous functions which vanish at 0.  Then use the Riesz representation theorem.)  In particular if $f \in L^1([0,1], dx)$ and $\int f(x) x^n \,dx = 0$ for all large $n$, then $f = 0$ a.e.