If $\int_a^b f(x)\;dx=(b-a)\sup\;f([a,b])$ where $f$ is continuous on $[a,b]$ then $f$ is constant in $[a,b]$ I got this question:
Let $f$ be a continuous function on $[a,b]$ that satisfies $\int_a^b f(x)\;dx=(b-a)\sup\;f([a,b])$, Must it be the case that $f$ is constant in $[a,b]$ ?
I tried to find a counterexample and to prove it but got stuck. 
Thanks.
 A: To begin with, $(b-a) \sup f([a,b])$ is an upper bound on the integral, $\int_a^b f(x)\, dx$. Now suppose that $f$ is not a constant function. Then there is a point $x_0$ for which $$f(x_0) < \sup(f) - \epsilon$$ for some $\epsilon > 0$. Let $\delta > 0$ be such that $f(x) < \sup(f) - \epsilon/2$ for all $|x-x_0| < \delta$. Then $$\int_{x_0 - \delta}^{x_0+\delta} f(x)\, dx < 2\delta \cdot \sup(f) - \delta \epsilon.$$
A: Let $m = \inf f$ and $M = \sup f$. Suppose that $m < M$ and that $f$ attains its infimum at $c$. (Assume $a < c < b$. If $c = a$ or $c = a$ you can modify the proof accordingly.) 
Let $m < t < M$. Since $f(c) = m$ and $f$ is continuous there exists $d < b$ with the property that $f(x) < t$ for all $x \in [c,d]$. Then
\begin{align*} \int_a^b f(x) \, dx &= \int_a^c f(x) \, dx + \int_c^d f(x) \, dx + \int_d^b f(x) \, dx \\
&\le (c-a) M + (d-c) t + (b-d)M \\
&< (b-a)M
\end{align*}
where the final inequality is strict since $t < M$. This contradicts the hypothesis so we conclude $m = M$, that is, $f$ is constant.
