$f$ nonnegative, continuous in $[a,b]$ and such that $\int_a^b f(x)dx=0$ implies $f(x)=0$ in $[a,b]$ My book proves the following statement: "Let $f$ be nonnegative and continuous in $[a,b]$ and such that
$$\int_a^b f(x)dx=0$$
then $f$ is identically $0$ in $[a,b]$." using an argument by contradiction.
However, I've tried to prove it in a direct way (which takes way more effort, but I would like to know if there is a flaw in my reasoning or not), can someone check if my work is okay please?
My try: by hypothesis $f$ is nonnegative in $[a,b]$: if $f(x)=0$, the theorem is true.
So let's suppose $f(x)>0$: let $x_0 \in [a,b]$, by hypothesis $f$ is continuous in $[a,b]$, so in particular it is continuous in $x_0$. Since $f$ is positive in this case, I can chooose $\epsilon=\frac{1}{2}f(x_0)$ in the definition of continuity to get the inequality $\frac{1}{2}f(x_0) \leq f(x) \leq \frac{3}{2}f(x_0)$ if $x_0-\delta_\epsilon < x < x_0+\delta_\epsilon$. Since by hypothesis $f$ is continuous in $[a,b]$, it is integrable in $[a,b]$ as well, so by monotonicity of integral it is
$$\int_{x_0-\delta_\epsilon}^{x_0+\delta_\epsilon} \frac{1}{2}f(x_0)\,dx \leq \int_{x_0-\delta_\epsilon}^{x_0+\delta_\epsilon} f(x)\,dx \leq \int_{x_0-\delta_\epsilon}^{x_0+\delta_\epsilon} \frac{3}{2} f(x_0)\,dx$$
By hypothesis $\int_a^b f(x)\,dx=0$, so in particular $\int_{x_0-\delta_\epsilon}^{x_0+\delta_\epsilon} f(x)\,dx=0$; hence from the last inequality it follows that $\delta_\epsilon f(x_0) \leq 0 \leq 3\delta_\epsilon f(x_0)$. Since $\delta_\epsilon>0$, This means that $f(x_0)$ is both $\geq0$ and $\leq 0$, the only possibility is that $f(x_0)=0$. Since $x_0 \in[a,b]$ is arbitrary, this holds for all $x\in[a,b]$ and so $f(x)=0$ for all $x\in[a,b]$.
Is this correct? If it is maybe I should've put more attention in the intervals of the kind $[a,x_0+\delta_\epsilon]$ and $[x_0-\delta_\epsilon,b]$ because since $\delta_\epsilon$ if $x_0$ is too much near the boundary I risk to "go out" of $[a,b]$, but I'm not sure if this is a problem or not since if $\delta_\epsilon$ works a lesser $\delta'_\epsilon$ would work too and so I can restrict it as much as I need.
 A: You must pick some $x_0$ such that $f(x_0)>0$, you can't just pick $x_0$ completely arbitrarily. It can easily happen that $f$ is only positive on, say, some small interval.
Other than that, yes, once $f(x_0)>0$, there is a nondegenerate interval containing $x_0$ on which $f(x)>f(x_0)/2$, and so the integral on that interval is positive. Meanwhile the integral elsewhere is nonnegative. So you conclude that if $f$ is nonnegative, continuous, and not identically zero, then its integral is nonzero, which is a contrapositive of the desired statement.
I would call this general type of argument either contradiction or contraposition, though, so I'm a bit surprised that you think this is especially direct.
A: The major points here are the right idea but this isn't necessarily a "direct proof" (if by direct you mean showing $p$ implies $q$) since you are saying that $f(x) > 0$ cannot happen by some contradiction.
One thing to note is that not every proof has a "direct way" to prove it as even some reasoning used in the proof could actually by due to contradiction or contrapositive
For example, let's consider another possible argument which is simply a modification of what you wrote here.
Say you take arbitrary $x_0 \in [a,b]$ and then show (using similar reasoning here) that for all $\epsilon > 0$, we have $f(x_0) < \epsilon$.
Then you would conclude that since $f(x_0) \geq 0$ that $f(x_0) = 0$.
However, the very fact that given a number $r \geq 0$, if $r \leq \epsilon$ for all positive $\epsilon$, then $r =0$ is proven necessarily with contradiction, so it can't always be avoided. This is part of the nature of real analysis.
A: If $f(x)$ is non-negative on $[a,b]$ then that suggests that $f(x)\ge0$ on $[a,b]$ and so:
$$\int_a^bf(x)dx\ge0$$
for a function to be non-zero and the integral be zero over $[a,b]$ there must be a point of discontinuity $c\in(a,b)$ such that:
$$\int_a^cf(x)dx=-\int_c^bf(x)dx$$
but this is a contradiction because this function is discontinuous and would have to be negative at some point, and so the only solution is:
$$iff\,\,\,\int_a^bf(x)dx=0,f(x)\ge0\Rightarrow f(x)=0$$
