A continuous nonnegative function with integral $0$ is identically $0$ (understanding why my approach is incorrect) Suppose $f$ is continuous on $[a,b]$, that $f(x) \geq 0 \ \forall x \in [a,b]$, and $\int_{a}^{b} f(x) dx = 0$. Prove that $f(x) = 0 \ \forall x \in [a,b]$
I have seen various posts on this:
If the Riemann Integral of a continuous nonnegative function is 0, then that function is identically 0.
$f\geq 0$, continuous and $\int_a^b f=0$ implies $f=0$ everywhere on $[a,b]$
and many more. I follow these proofs, but I want to understand why mine is incorrect. I will explain why I know it is flawed after showing it since without context, it won't make sense.
Since $f$ is continuous, the mean value theorem for integrals tells me $\exists c \in (a,b)$ s.t.
$f(c) = \frac{\int_{a}^{b} f(x)dx}{b-a} = \frac{0}{b-a} = 0$
Now, since $f$ is continuous on $[a,b]$, specifically, it is continuous at $c$, I know $\forall x \in [a,b], \forall \epsilon > 0, \exists \delta > 0$ s.t. whenever $|x - c| < \delta, |f(x) - f(c)| < \epsilon$.
But, $f(c) = 0$. So, $|f(x) - f(c)| = |f(x)| < \epsilon$
Therefore, $f(x) = 0$
Now, the reason I know my proof is flawed is because I never used the fact that $f(x) \geq 0$. This assumption cannot be dropped as there are a plethora of counterexamples (for one of many counterexamples, take $\sin(x)$ on $[0,2\pi]$). Despite knowing this, and reading the other proofs, I am still struggling to see where the invalid step is in my proof. I'd like to understand what part of my proof is incorrect that way I won't make a similar mistake again on other proofs. Does anyone see where I made a false move? Thanks in advance!
 A: As $\epsilon$ gets smaller, the $\delta$-interval around $c$ where $|f(x)| \lt \epsilon$ is true gets smaller.
In order for "$\forall \epsilon \gt 0, |f(x)| \lt \epsilon$" to imply "$f(x) = 0$", it has to be true for some fixed $x$. In your argument, the location of $x$ "moves around" as you change $\epsilon$.
It's possible that $x$ may be "fixed but arbitrary", and the argument still works, but your $x$ has a (hidden) dependence on $\epsilon$.
If you want to see this in action, let $f(x) = x-\frac{1}{2}$ on $[0,1]$. Then $c = \frac{1}{2}$, and you can explicitly compute $\delta$ in terms of $\epsilon$. Fix a value of $x$ near (but not at) $\frac{1}{2}$, and as you let $\epsilon$ get smaller, your fixed $x$ value will at some point no longer lie in $(c-\delta, c+\delta)$, and $|f(x)| \lt \epsilon$ will stop being true.
(Incidentally, this problem of using variables to represent values, and not tracking if it represents a fixed value, or ranges over some set, and whether or not it depends on another variable, happens all the time. Our notation is bad at encoding it, and teachers would rather not get bogged down spending time to make it explicit. Making mistakes with it so that you learn to not make them again in the future is part of the infamous "mathematical maturity".)
A: It is not true that $|f(x)|<\epsilon$ for all $x$ in the domain. It is only true that  $|x-c|<\delta\implies |f(x)|<\epsilon$ for all $x$ in the domain.
Your argument relies on considering the limit as $\epsilon\to 0$, but $\delta$ is dependent on $\epsilon$ and so whether the premise $|x-c|<\delta$ holds depends on $\delta$. If $\delta\to 0$ as $\epsilon\to 0$ then for any $x\neq c$, the statement $|x-c|<\delta$ will stop being true for sufficiently small $\epsilon$, so we cannot conclude $|f(x)|<\epsilon$ for all $\epsilon$. (This doesn't mean that $|f(x)|\ge \epsilon$, just that we cannot make a conclusion one way or the other.)
It would be too cumbersome to enforce variable names that emphasise the dependence on other variables e.g. in place of $\delta$, using $\delta_{\epsilon_x,x}$ (as $\epsilon$ depends on $x$ and $\delta$ on $x,\epsilon$) or $\delta(\epsilon(x), x)$, but it can be a useful exercise to use a variable like $\delta_\epsilon$ here or there when you are uncertain about whether a limiting argument is correct, what the order of quantifiers should be, or in which order the process of "fixing a value of $\epsilon$; then finding a $\delta$" takes place.
