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..
 A: Consider
$$
h(x)=f(x)-\frac{1}{b-a}\int_a^b f(t)\,dt.
$$
It suffices to show that $h\equiv 0$. In turn, it suffices to show that
$$
\int_a^b h(x)w(x)\,dx=0, \quad\text{for all $w:[a,b]\to\mathbb R$ continuous}.
$$ 
Take one such $w$, and let $\tilde w(x)=w(x)-\dfrac{1}{b-a}\int_a^b w(t)\,dt$. Then $\int_a^b \tilde w(x)\,dx=0$, and hence we know that
$$
0=\int_a^b f(x)\tilde{w}(x)\,dx=\int_a^b f(x){w}(x)\,dx-
\frac{1}{b-a}\left(\int_a^b w(x)\,dx\right)\int_a^b f(x)\,dx \\
=\int_a^b f(x){w}(x)\,dx-
\frac{1}{b-a}\left(\int_a^b f(x)\,dx\right)\int_a^b w(x)\,dx \\
=\int_a^b h(x){w}(x)\,dx.
$$
In particular, if $w=h$, then we obtain that $\int_a^b h^2(x)\,dx=0$, and hence $h\equiv 0$.
A: 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$.
A: You can also consider the Hilbert space $H=L^2([a,b])$ for this; set $$K=\left\{h\in H\Big{|}\int_a^bh(x)\,dx=0\right\},$$ then $K$ is a subspace of $H$, of codimension $1$. From density, we should have that $\left<f,h\right>=0$ for any $h\in K$, where $\left<\cdot,\cdot\right>$ is the inner product in $H$, therefore $f\in K^{\perp}$. But, $K^{\perp}$ has dimension $1$, and constant functions are contained in it, therefore $K^{\perp}$ is the subspace of constant functions. This shows that $f$ is a constant.
