Let $I$ be a bounded interval of $\mathbb{R}$ and $f$ be a continuous function on $I$.
Assume $I$ is closed, ie: $I=[a,b]$, and $\forall n\geq 0$, $\int_I x^n f(x)dx=0$. Then, one can show with Weierstrass approximation that $f=0$ on $I$.
This can be done because, with this assumption, $I$ is compact so one can apply Weierstrass theorem. But someone told me that the result holds even though $I$ is open, ie: $I=(a,b)$.
How can this be done ?
If you assume that $f$ is absolutely integrable on $(a,b)$, then you can get what you want. To see this, suppose $g$ is continuous on $[a,b]$. Then the Weierstrass approximation theorem gives you a sequence $\{ g_n \}$ of polynomials on $[a,b]$ that converges uniformly to $g$. Therefore, $$ \left|\int_{a}^{b}g_n f dx - \int_{a}^{b}g fdx\right| \le \int_{a}^{b}|f(x)|dx\cdot\sup_{x\in [a,b]}|g_n(x)-g(x)|\rightarrow 0 \mbox{ as } n\rightarrow\infty. $$ Because $\int_{a}^{b}g_n(x)f(x)dx = 0$ for all $n$, it follows that $$ \int_{a}^{b}g(x)f(x)dx=\lim_n \int_{a}^{b}g_n(x)f(x)dx=0. $$ The above must hold for all $g \in C[a,b]$. Fix a subinterval $[c,d]\subset (a,b)$ and define $g_{\delta}(x)$ to be $f$ on $[c,d]$, to be $0$ on $(a,c-\delta)\cup(d+\delta,b)$, and to be linear and continuous on the remaining intervals $[c-\delta,c]\cup[d,d+\delta]$. Then $$ 0=\lim_{\delta\downarrow 0}\int_{a}^{b}f(x)g_{\delta}(x)dx=\int_{c}^{d}f(x)^2dx. $$ The above holds for all $a < c < d < b$. And $f(x)^2$ is continuous on $(a,b)$. By the Fundamental Theorem of Calculus, $$ 0=\frac{d}{dy}\int_{c}^{y}f(x)^2dx=f(y)^2. $$