Proving $\,f$ is constant. Let $\,f:[a,b] \rightarrow  \Bbb R $ be  continuous 
and  $\int_a^b f(x)g(x)\,dx=0$, whenever $g:[a,b] \rightarrow  \Bbb R $ is  continuous and $\int_a^b g(x)\,dx=0$.
Show that $f$ is a constant function.
I tried a bunch of things including the mid-point integral theorem(?) but to no avail.
I'd appreciate an explanation of a solution because I really don't see where to go with this one..

Suppose $f$ is nonconstant.
Define $g(x) = f(x)-\bar{f}$, where $\bar{f}:= \frac{1}{b-a} \int_a^b f(x)dx$. Then $\int_a^b g = 0$.
Then $$\int_a^b f(x)g(x)dx = \int_a^b f(x) \big(f(x)-\bar{f}\big) dx = \int_a^b \big(f(x)-\bar{f}\big)^2 dx >0$$ The reason that this last term is larger than zero, is that $f$ is non-constant, so we can find at least one value $x \in [a,b]$ such that $f(x) \neq \bar{f}$. By continuity, there exists some interval $[c,d] \ni x$ such that $f(y) \neq \bar{f}$ for $y \in [c,d]$, and thus $(f(y)-\bar{f})^2>0$ for $y\in [c,d]$.
Thus if $f$ is nonconstant, then we can find at least one $g$ for which $\int_a^b g = 0$ and $\int_a^b fg >0$.
