# Integral of rationals

Define $f(x)$ as $$f(x)=\begin{cases}0,&\text{if }x\in \mathbb{Q}\\ 1,&\text{if }x\notin \mathbb{Q}\;. \end{cases}$$ Considering the fact that there is a countable infinity of rationals yet an uncountable infinity of irrationals between $0$ and $1$, can the following statement be made? If yes, why? if not, why not? $$\int_0^1f(t) dt=1$$

It depends if you're talking about a Riemann integral or a Lebesgue integral.

If we are talking about a Riemann integral, the answer is that we cannot define the integral because any sub-interval of $[0,1]$ - no matter how small - contains a rational and an irrational. For this reason the upper integral and lower integral will not be the same (here the $\sup f = 1$ and $\inf f = 0$ on any sub-interval).

If you are talking about a Lebesgue integral, the answer is yes. This is because integrating over $[0,1]$ and $[0,1] \setminus \mathbb Q$ will give the same answer under certain conditions. You'd need to know a little bit of measure theory to completely understand the details, but the formulation of the Lebesgue integral tells you that integrating over a set of measure zero (the rationals for example) will be zero, and thus $$\int_{[0,1]} f(t) dt = \int_{[0,1] - \mathbb Q} f(t) dt + \int_{\mathbb Q} f(t) dt = \int_{[0,1]- \mathbb Q} 1 dt + 0 = 1$$

I'm omitting some details, but hopefully this provides some insight.

• This function is also integrable using techniques like the MacShane integral or the Kurzweil-Henstock integral, and can be a good illustration of why they are more powerful than the Riemann integral.
– jwg
Nov 4 '15 at 9:56

$f$ isn't Riemann-integrable but Lebesgue-integrable and indeed its integral is $1$, because $f=1$ almost everywhere on $[0,1]$, since $\mathbb{Q}$ is countable.

It depends on your definition of integral. The Riemann integral, the first one taught in calculus classes, does not have a value because the lower sum is always zero and the upper sum is always one. The Lebesgue integral of this function exists and is $1$ as your intuition suggests.

If $f$ is not continuous, the Riemann integral may not exist. In this case, by splitting the range into intervals and picking numbers in the range, it is possible to pick only rational numbers, forcing the value of the integral to $0$. It is also perfectly valid to pick only irrational numbers, forcing the value of the integral to be $1$. Since no such value can be derived, it cannot be Riemann integrated.

The Lebesgue integral deals with the measure of the irrational numbers and the measure of the rational numbers, since the measure of the rational numbers is $0$, while the measure of the irrational numbers is $1$, hence the integral evaluates to $1$.