real analysis and integral Let $f$ be a continuous function on $[a, b]$ satisfying
$$\int_a^b f(x)g^\prime(x)\,\mathrm{d}x = 0$$
whenever $g$ is a continuously differentiable function on $[a, b]$ satisfying $g(a) =
g(b) = 0$. 
Show that $f$ must be constant. 
 A: Let 
$$\tilde{f}(x)=f(x)-\frac{1}{b-a}\int_a^bf(x)dx.\tag{1}$$
Then from the assumption on $f$ we know that for every continuously differentiable function $g$ on $[a,b]$ with $g(a)=g(b)=0$, we have
$$\int_a^b \tilde{f}(x)g^\prime(x)\,\mathrm{d}x = 0. \tag{2}$$
By definition $(1)$, it suffices to show that $\tilde{f}\equiv 0$.
Let
$$g(x)=\int_a^x\tilde{f}(t)dt.\tag{3}$$
Clearly $g$ is continuously differentiable on $[a,b]$ and $g(a)=g(b)=0$. Substituting $(3)$ into $(2)$, we have:
$$\int_a^b(\tilde{f}(x))^2dx=0.\tag{4}$$
The conclusion follows from $(4)$ immediately.
A: Hint: Choose any two points $c \neq d$ in $(a, b)$.
Let $\varphi(x) = \max \{ 1 - |x|, 0 \} $ a bump near $x = 0$, and let
$$g_{\epsilon}(x) = \int_{a}^{x} \frac{1}{\epsilon} \left( \varphi\left(\frac{t-c}{\epsilon}\right) - \varphi\left(\frac{t-d}{\epsilon}\right) \right) \, dt. $$
For sufficiently small $\epsilon$, $B_{\epsilon}(c), B_{\epsilon}(d) \subset (a, b)$ and we have $g_{\epsilon}(a) = g_{\epsilon}(b) = 0$. Also, it is not hard to show, by continuity of $f$, that
$$ \int_{a}^{b} f(x) g_{\epsilon}'(x) \, dx \to f(c) - f(d) \quad \text{as} \quad \epsilon \to 0. $$
Thus $f(c) = f(d)$ for all such $c, d$ and it follows that $f$ is constant on $[a, b]$.
