Does there exist such a Riemann integrable function? I am curious, does there exist a Riemann integrable function $f: [a,b] \to \mathbb{R}$ that satisfies the following three criteria?
$\hspace{20pt}$ $1$. $f$ is a positive function, that is, $f(x) \geqslant 0$ for all $x \in [a,b]$
$\hspace{20pt}$ $2$. There exists an infinite subset $I$ of $[a, b]$ such that $f(x) > 0$ for each $x \in E$
$\hspace{20pt}$ $3$. $\int_a^b f(x)dx=0$
I was initially thinking about a constant function, but then the integral is greater than $0$ if criteria $2$ is met. If such a function exists, what is an elementary example?
 A: Define $f:[0,1]\to\mathbb{R}$ by $f(\frac{1}{n})=1$ for all $n\in\mathbb{N}$, and $f(x)=0$ otherwise. This function is Riemann integrable, because it is continuous everywhere outside of a set of measure zero. The integral is zero because $f=0$ outside of a set of measure zero.
A: Just to address @B.S.Thomson complaint, take @Lorago's function and an arbitrary $\epsilon>0$, and take the interval $[a,a+\epsilon/2]$.
As $a+\frac{b-a}{n}\to a$, it follows that all the points of $E$ with the exception of a finite number belong to $[a,a+\epsilon/2]$.
Cover the remaining finite number of points with intervals of length at most $\epsilon/2, \epsilon/4,\ldots$ centered in those points, taking care not to overlap other intervals or points.
Now use the endpoints of those finite intervals to generate a partition of $[a,b]$. Now it's easy to see that the upper Darboux sum of this partition is at most $\epsilon/2+\epsilon/4+\ldots<\epsilon$. In other words, $\int_a^bf(x)\,dx=0$
A: Take the following function $f\colon [0,1]\to \mathbb{R}$,
$f(x)=0 \text{ if } x\notin C$ and $f(x)=1 \text{ if } x\in C$ where $C$ is the Cantor so that the set of discontinuities is a Lebesgue null set and hence Riemann-integrable. Hence $f\geq 0$ on $[0,1]$, $f(x)>0$ on the infinite set $C$ and
$$\left|\int_a^b f(x) dx\right|\int_a^b |f(x)| dx \leq \int_{C^C} |f(x)|dx + \int_C |f(x)|dx =0+ \lambda(C)=0.$$
A: Recall that a bounded function $f:[a,b]\to\mathbb{R}$ is Riemann integrable if and only if it is continuous almost everywhere (in the Lebesgue sense). We thus consider a "nice" infinite set with measure zero, say let
$$E=\left\{a+\frac{b-a}{n} : n\in\mathbb{Z}^+\right\}.$$
Now clearly $E$ is a countably infinite set, and so it has Lebesgue measure zero. Now set
$$f=\chi_{E},$$
i.e. the characteristic function of $E$. Check for yourself that this function is continuous a.e., and thus Riemann integrable. Now in this case the Riemann and Lebesgue integrals also coincide, and so
$$\int_a^b f(x)\,\mathrm{d}x=\int_E\mathrm{d}\lambda=\lambda(E)=0,$$
where $\lambda$ is the Lebesgue measure on $\mathbb{R}$. Thus such a function does indeed exist. Now if you don't know any Lebesgue integration, see if you can prove that this function indeed has Riemann integral zero using the definition or some other nice theorem, but I'll leave that up to you.
