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?