$f,g$ continuous functions, $f$ strictly increasing, non-vanishing: $\int_a^bg(x)(f(x))^n\,dx=0$ for all $n$ $\Rightarrow g\equiv 0$ While studying for an exam, I came across the following problem.

Suppose $[a,b]\subset\mathbb{R}$ and $f:[a,b]\rightarrow\mathbb{R}$ is a strictly increasing non-vanishing continuous function. Suppose $g:[a,b]\rightarrow\mathbb{R}$ is a continuous function which is orthogonal to all powers of $f$, i.e. is such that $\int_a^bg(x)(f(x))^n\,dx=0$ (Riemann integrals) for $n=1,2,3,\ldots$. Show that $g(x)=0$ for all $x\in[a,b]$.

Since I could not think of how to solve this problem, I considered something simpler.
I know that if $f(x)=x$, then we have $\int_a^bg(x)x^n\,dx=0$ for all $n$. Applying the Weierstrass Approximation Theorem to $g$, we obtain a sequence of polynomials $(p_n)$ such that $p_n\rightarrow g$ uniformly. Therefore, by linearity of the integral, we have
$$\int_a^bg(x)p_n(x)\,dx=0$$
for all $n$. Thus
$$\lim_{n\rightarrow\infty}\int_a^bg(x)p_n(x)\,dx=\int_a^b(g(x))^2\,dx=0.$$
Since $g$ is continuous, the result follows.
But, obviously, this is not an answer to the stated question...
Any help would be greatly appreciated. Thanks in advance.
 A: The full Stone-Weierstrass Theorem is as follows:

Let $X$ be a compact Hausdorff space.  If $\mathcal{A}$ is set of
   continuous real-valued functions on $X$, and if $\mathcal{A}$
   satisfies the following conditions, then $\mathcal{A}$ is dense in
   $C(X,\mathbb{R})$, the set of all continuous real-valued functions on
   $X$ with the uniform metric; that is, every continuous $f: X
 \rightarrow \mathbb{R}$ is a uniform limit of functions in
   $\mathcal{A}$:
(i) $\mathcal{A}$ is an algebra; that is, $A$ is closed under
  addition, multiplication and scalar multiplication
(ii) $\mathcal{A}$ contains a non-zero constant function (hence all constants, by (i))
(iii) $\mathcal{A}$ separates points: for any distinct $x,y \in X$,
  there is $f \in \mathcal{A}$ so that $f(x) \neq f(y)$.

This is a rather shockingly powerful generalization of the Weierstrass Approximation theorem: any closed interval $[a,b]$ is compact and Hausdorff, and the set of polynomials on $[a,b]$ satisfies the conditions (i)-(iii), hence any continuous function $f: [a,b] \rightarrow \mathbb{R}$ can be approximated by polynomials.
To make use of this theorem, we don't have to "find" such a set in the wild - instead, we build it ourselves, forcing it to obey condition (i) and then hoping that (ii) and (iii) hold as well.
Thus for this problem we define $\mathcal{A}$ to be the set of all polynomials in $f(x)$; that is, all functions of the form $a_0 + a_1f(x) + a_2f(x)^2 + \ldots + a_nf(x)^n$, with coefficients in $\mathbb{R}$.  This is the smallest set containing $f(x)$ that satisfies (i) and (ii).  Now show that $\mathcal{A}$ (iii).  Then given any continuous function $f(x)$, you can approximate it by a sequence of functions in $\mathcal{A}$ and your proof goes through exactly as you wrote it for the special case.
