If $f \in \mathcal{R}[a, b]$ and $f(x) \geq 0$ almost everywhere, prove that $\int^b_a f\geq 0$ Say that $f \in \mathcal{R}[a, b]$ and $f(x) \geq 0$ almost everywhere.
I'm trying to prove that $\int^b_a f\geq 0$
I know that a set of $x \in [a, b]$ such that $f(x) < 0$ has measure zero.
Also, an interval of positive length will not be a set of measure $0$, so the interval defined in the first line will not be a set of measure $0$.
Is this just a case of "almost everywhere" meaning that the positive values of $f(x)$ vastly number the negative values, so the overall integral value on the interval is greater than or equal to $0$. [Depending on how negative the negative values are, I suppose]
Any thoughts on a more formal proof?
 A: If $f(x) \ge 0$, almost everywhere, then in every subinterval $[s,t]\subset [a,b]$, there exist a $\xi$, such that $f(\xi)\ge 0$, and in particular,
$$
\sup_{x\in [s,t]}f(x)\ge 0.
$$
Hence, for every partition $P=\{a=t_0<t_1<\cdots<t_n=b\}$ of $[a,b]$, if $$M_i=\sup_{x\in [t_{i-1},t_i]}f(x),$$ then $M_i\ge 0$, and thus the corresponding upper sum $$U(f,P)=\sum_{i=1}^nM(t_i-t_{i-1}),$$ is non-negative.
Since $f$ is Riemann integrable over $[a,b]$, then
$$
\int_a^b f(x)\,dx=\inf_P U(f,P)\ge 0.
$$
The infimum above is taken over all partitions of $[a,b]$.
A: Since $f$ is a priori assumed to be Riemann integrable, we know that picking any sequence of tagged partitions with its length (/mesh/content) going to $0$ lets us compute the Riemann integral.
For ease of notation, let us assume that $[a, b] = [0, 1]$. Let $\cal{P}_n$ be the uniform partition of $[0, 1]$ into $n$ parts.
Since $f \geqslant 0$ a.e., for each $i \in \{0, \ldots, n - 1\}$, there exists $t_i \in [i/n, (i + 1)/n]$ such that $f(t_i) \geqslant 0$.
(Since no nondegenerate interval can be contained in a measure zero set.)
The Riemann sum for this tagged partition is clearly nonnegative. Since the limit of a (convergent) nonnegative sequence is again nonnegative, we are done.
A: If we denote $A = \{x \in [a,b] : f(x) < 0\}$, then $\mu(A) = 0$ by the condition. Hence,$$\int\limits_{[a,b]}f(x)dx = \int\limits_{[a,b]\setminus A} f(x) dx + \int\limits_{A} f(x) dx = \int\limits_{[a,b]\setminus A} f(x) dx \ge 0$$
