# Integral of function ($1$ if irrational, $2$ if rational)

Problem: Let the function $$f$$ be defined such that $$f(x)=\begin{cases} 1 \quad x\in\mathbb{R}\backslash\mathbb{Q}\\ 2 \quad x\in \mathbb{Q}\end{cases}.$$

Compute the folowing integral: $$\quad\int_0^1 f(x)\,dx$$.

Would it be $$1$$ because there are infinitely many irrational numbers between each rational number?

I don't even know where to start with this.

• Exactly what is your definition of a definite integral like $\int_a^bg(x)dx$? The answer to your problem will depend heavily on this. Mar 26, 2017 at 20:37
• @Arthur What is your definition of it? How would you integrate it using yours... I don't have any clue, I guess for me it would be the area under the curve, but clearly that doesn't make sense Mar 26, 2017 at 20:45
• It's usually some form of limit, and the word "partition" probably appears. Maybe even two simultaneous limits which should be equal. Does this ring any bells? Doesn't your book tell you? To be more specific, even whether your integral has a value or is undecidable depends on what definition you're using. Mar 26, 2017 at 20:48
• There are infinitely many rational numbers between any two irrational numbers too. Not quite the same kind of "infinite"--but how you tell they're different kinds of "infinite" is the problem. Jun 24, 2021 at 0:58

## 2 Answers

Riemann integral: $\int_0^1 f(x) dx$ is undefined, because the refinement of the partition of the interval does not result in a converging Riemann sum.

Lebesgue integral: $f\equiv 1$ almost everywhere, because the rational numbers are a countable set, which means that they are a set of measure zero and do not have any impact on the result. Therefore, $\int_0^1 f(x) dx = 1$

It could depend on exactly how you are defining integration. Have you heard the phrase "almost everywhere"? It means that the exceptions are a set of measure zero. In the reals, any finite or countable set has measure zero. So, your function is equal to 1 almost everywhere. Even some uncountable set have measure zero; not all, of course.

Almost everywhere at Wikipedia

Almost everywhere at Wolfram MathWorld