1

I have been under the assumption that Integrate performs Riemann integration. But when I try to integrate the Dirichlet function, it evaluates to $0$.

Dirichlet function is defined as follows: $$ f(x) = \begin{cases} 1 & x\in\mathbb{Q} \\ 0 & x\notin\mathbb{Q} \end{cases} $$ Under Riemann integration, this function is not integrable; but under Lebesgue integration, this function evaluates to $0$.

So does it mean Integrate performs Lebesgue integration? Or is it neither and I am not even asking the correct question to begin with? Couldn't find anything in the documentation about this.

EDIT: My implementation of Dirichlet function is as follows:

f[x] := Piecewise[{{1, Element[x, Rationals]}, {0, True}}]

And the code for the integral is simply

Integrate[f[x], {x, 0, 1}]
Tham
  • 111
  • 2
  • Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory [tour] now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. – bbgodfrey Sep 29 '21 at 20:13
  • 1
    How are you implementing the Dirichlet function in Mathematica? I can't find a built-in, so you should include your code for it (or tell us what built-in function you are using). Also, are you using Integrate or NIntegrate to do the integral? Your code would be useful here as well. – Michael Seifert Sep 29 '21 at 20:29
  • @MichaelSeifert I implemented it by doing a piecewise function with the condition x \[Element] Rationals; sorry, I'm not sure how to put in Mathematica code here yet.. And I used Integrate (not NIntegrate), but from $x=0$ to $x=1$ – Tham Sep 29 '21 at 21:39
  • 8
    Mathematica is mostly a tool of applied mathematics. As such, it reflects the pragmatism of applied mathematicians. Integrate uses whatever theory of integration it can bring to bear to find a useful answer. – John Doty Sep 29 '21 at 22:36
  • 1
  • @MichaelE2 Thank you, I have edited my code. – Tham Sep 29 '21 at 23:46
  • 1
    @JohnDoty That makes sense, thank you so much! – Tham Sep 29 '21 at 23:46

0 Answers0