This is a small real analysis problem that is a part of another problem I'm tackling, and I strongly believe that the following claim is true, but for some reason I'm unable to prove this using elementary real analysis. Could I please get some hints/advice? I don't think it's hard.
Say $f$ is a continuous real-valued function on $[0,1]$, and $c$ is some upper bound on the function $f$ on $[0,1]$. Also say that $\int_0^1 f(x) dx = c$. Then surely $f$ is equal to $c$ on all of $[0,1]$. Could I please get some help in proving this elementary fact that I believe is true?
Hint. Show that if $g(x):=c-f(x)$ is a non-negative continuous function in $[0,1]$ and $$\int_0^1 g(x) dx = 0$$ then $g$ is identically zero. Assume by contradiction that $g(x_0)>0$ for some $x_0\in [0,1]$ and use the continuity of $g$ at $x_0$.
P.S. Then see Given $f(x)$, a continuous function on [0, 1] st $f(x)≥0$ for all $x∈[0, 1]$, show that if $\int_0^1 f(x)dx=0$ then $f(x) = 0$ for all $x ∈ [0, 1]$?