$f = 0$ outside a set of measure zero implies $\int_a^b f \, dx= 0$ Let $f \colon [a,b] \to \mathbb R$ bounded, such that $f(x) = 0$ for every $x \in [a,b]$ except in a set $J$ of measure zero. When we say that a set $J$ has measure zero, if given any $\varepsilon  > 0$ there exist a countable collection of open intervals $( a_n ,b_n)$ such that $J \subset \bigcup\limits_{n \in \Bbb N} (a_n ,b_n)$ and $\sum \limits_{n \in {\Bbb N}} (b_n  - a_n) < \varepsilon$. Prove that in the Riemann sense (I don't know any other sense of integrals) the integral exist and $$
\int_a^b f (x) \, dx = 0.
$$
The existence is easy, but how can I prove the equality? Help me with this please.
Don't use Lebesgue integrals, because I can't use it in this exercise. It's from a real analysis course. Thanks!
I know that this result it's more general, Instead of putting $f(x) = 0$, I can put any Riemann integrable function, but the general case, comes off as trivial corollary of this. So why try to prove this.
 A: I would've thought the existence would be harder.
Assuming you already proved the existence, let $\varepsilon>0$ and let $M$ be the bound on $f$.
You can cover $J$ with a set of intervals whose accumulated length is less than $\varepsilon$.
If you assume that all the intervals are pairwise disjoint, you get that the integral is bound from above by $\varepsilon M$, and relaxing that demand can only reduce the value of the integral.
This asserts that the value of the integral can be bound from above by $\varepsilon M$ for any $\varepsilon >0$, as needed.
A: For the reason Michael Hardy indicated in a comment, the statement is incorrect.  If you assume that the function is Riemann integrable, then Shai Deshe's answer applies.
But you're correct that if both $f$ and $g$ are Riemann integrable and $f=g$ almost everywhere, then $\int_a^b f(x)\,dx=\int_a^b g(x)\,dx$.  This could be shown directly using reasoning similar to that in Shai Deshe's answer.  
You mention that the initial problem is a trivial corollary of the more general case (at least I think that's what you meant).  But it turns out that the general case is also a trivial corollary of the special case!  If $f(x)=g(x)$ almost everywhere and both $f$ and $g$ are Riemann integrable, then $h(x)=f(x)-g(x)$ is Riemann integrable, and $h(x)=0$ almost everywhere.  So $\int_a^b h(x)\,dx=0$, and since $\int_a^b h(x)\,dx=\int_a^b f(x)\,dx-\int_a^b g(x)\,dx$, the general result follows.
