Let $f$ be continuous on $[0,1]$ and suppose $\int_0^1f(x)x^ndx=0$ for all $n\in\mathbb{N}_0$. Prove that $f=0$.
*Let $\epsilon\geq 0$. By Weierstrass theorem, we can find a polynomial $p(x)$ such that $|p(x)-f(x)|<\epsilon$, $\forall x\in[0,1]$.
Since $\int_0^1 f(x)x^ndx=0$, then $\int_0^1 f(x)p(x)dx=0$ (Why is this true? Could someone help me with details of rewriting it in terms of a polynomial?)
Since $f$ is continuous on $[0,1]$, $f$ is bounded, so assume $|f(x)|\leq M$ on $[0,1]$.
$|\int_0^1 f(x)^2 dx|=|\int_0^1 f(x)(f(x)-p(x))dx|\leq M\times\epsilon\times(1-0)$ so by letting $\epsilon\rightarrow 0$, we can have $\int_0^1 f(x)^2dx=0$. By continuity of $f(x)^2$, we can conclude that $f(x)=0$ therefore.
Seems like as long as the interval is finite, not only we can apply Weierstrass theorem but also after applying that we can have $\int_a^bf(x)^2 dx=0$ for all $a,b\in\mathbb{R}$, right? What about negative domain?