If $f:[a,b]\to \mathbb{R}$ is continuous and nonnegative and $\int_a^b{f}=0$, then $f(x)=0$ for all $x\in [a,b]$

Suppose that a function $f:[a,b]\to\mathbb{R}$ is continuous and nonnegative. Prove that if $\int_a^b{f}=0$, then $f(x)=0$ for all $x\in [a,b]$.

I've been trying to prove it using the extreme value theorem, continuity and the
upper and lower sums but can't come up with something tight enough. More specifically,
I've been trying to relate $|f(x)-f(t)|<\epsilon$ to the sum of $M_k-m_k(x_k-x_{k-1})$


Solution 1:

Assume $f(x_0) > \epsilon > 0$ for some $x_0 \in (a, b)$. By continuity, we can find $\delta > 0$ so that: $$ \forall x \in (x_0 - \delta, x_0 + \delta)\subset [a, b] : \left|f(x) - f(x_0)\right| < \frac{\epsilon}{2} $$

By the reverse triangle inequality, $\left|f(x)\right| > \left|f(x_0)\right| - \dfrac{\epsilon}{2} > \dfrac{\epsilon}{2}$.

Thus: $$ \int_a^b f(x) \,dx \ge \int_{x_0 - \delta}^{x_0 + \delta} f(x) \,dx \ge 2\delta \frac{\epsilon}{2} = \delta \epsilon > 0 $$

Solution 2:

Hint: If you suppose $f(x)\neq 0$ for all $x$, then there is some $x$ such that $f(x)>0$. This means there is some interval around $f(x)$, say $(-\varepsilon,\varepsilon)$ such that $f(x)>\delta>0$. This means $$\int_a^bf(x)\,dx\geq\int_{-\varepsilon}^\varepsilon f(x)\,dx\geq\delta\int_{-\varepsilon}^\varepsilon\,dx=2\varepsilon\delta>0,$$a contradiction. I'll leave justifying the details to you.

Solution 3:

If not $\exists~c\in[a,b]$ such that $f(c)>0.$ Now $f,\underline{0}\in\mathcal C[a,b]$ with $f\geq\underline{0}$ and $f(c)>\underline{0}(c).$ Consequently $\int_a^bf>\int_a^b\underline{0}=0,$ a contradiction.