Proving a continuous function is constant For a closed interval $I=[a,b]$, consider the $C^1$-functions that are $0$ at the endpoints, denoted $C^1_0(I)=\{f\in C^1(I)\,|\,f(a)=f(b)=0\}$. Let $g\in C^0(I)$, but not necessarily differentiable. Suppose
\begin{equation}
\int_a^b gf'\text{dx}=0\,\quad \forall f \in C^1_0(I)\,.
\end{equation}
I am asked to prove that $g$ is constant on $I$. Obviously, I can not use integration by parts as $g$ is not differentiable. I thought about construction of a test function in a smart way, but I have trouble creating test-functions that are continous, satisfying the boundary conditions. Any hints?
 A: If $g$ is not constant, there are $s,t\in (a,b)$ with $s<t$ such that $g(s)\neq g(t)$. Let $f\in C^1_0(I)$ be such that it rises to $1$ in a small interval around $s$, and in a completely symmetrical way sinks down to $0$ in a small interval around $t$. Otherwise $f$ is constant.
Use continuity of $g$ to show that if the two intervals are narrow enough, there is no way we can have $\int_a^b gf'\, dx=0$.
A: Apply your property to the $\mathcal{C}^1_0(I)$ function
$$f : t \mapsto \int_a^t g(x) \mathrm{dx} - \frac{t-a}{b-a} \int_a^b g(x) \mathrm{dx}$$
You get that
$$\int_a^b g^2(x) \mathrm{dx} = \frac{1}{b-a} \left(\int_a^b g(x) \mathrm{dx}\right)^2$$
The equality case of Cauchy-Schwarz implies that $g$ must be constant.
A: Here is a proof which is very similar to the answer given by TheSilverDoe, but it might provide more insight:

*

*Which functions can be written as $f'$, $f \in C_0^1(I)$? These are exactly the functions with zero mean, $M :=  \{f \in C(I) | \int_I f \, \mathrm{d} x = 0\}$.
Thus,
$$\int_I g \, f \, \mathrm{d}x = 0 \qquad\forall f \in M.$$


*For every $C \in \mathbb{R}$, we have $\int_I C \, f \, \mathrm dx = 0$ for all $f \in M$, thus,
$$\int_I (g - C) \, f \, \mathrm{d}x = 0 \qquad\forall f \in M.$$


*We can pick $C \in \mathbb R$ such that $g - C \in M$. Using $f = g - C$ yields
$$ \int_I (g-C)^2 \, \mathrm dx = 0$$
and therefore $g = C$.
