Mathwords logoMathwords

Dirichlet Function — Definition, Formula & Examples

The Dirichlet function is a function that equals 1 at every rational number and 0 at every irrational number. It serves as a classic example of a function that is discontinuous everywhere.

The Dirichlet function D:R{0,1}D: \mathbb{R} \to \{0, 1\} is defined by D(x)=1D(x) = 1 if xQx \in \mathbb{Q} and D(x)=0D(x) = 0 if xQx \notin \mathbb{Q}. Equivalently, DD is the indicator (characteristic) function of the rational numbers. It is nowhere continuous and is the standard example of a function that is Riemann non-integrable on any interval [a,b][a,b] with a<ba < b, yet Lebesgue integrable with integral zero.

Key Formula

D(x)={1if xQ0if xQD(x) = \begin{cases} 1 & \text{if } x \in \mathbb{Q} \\ 0 & \text{if } x \notin \mathbb{Q} \end{cases}
Where:
  • xx = A real number
  • Q\mathbb{Q} = The set of all rational numbers

How It Works

Between any two real numbers, there exist both rationals and irrationals (density of Q\mathbb{Q} and RQ\mathbb{R} \setminus \mathbb{Q}). This means the Dirichlet function oscillates between 0 and 1 in every interval, no matter how small. Because of this, the function has no limit at any point, making it discontinuous everywhere. For Riemann integration, upper sums on any interval always equal the interval length while lower sums always equal zero, so the upper and lower Riemann integrals never agree. Under Lebesgue integration, since Q\mathbb{Q} has measure zero, D=0D = 0 almost everywhere, giving abD(x)dx=0\int_a^b D(x)\,dx = 0.

Example

Problem: Show that the Dirichlet function is not Riemann integrable on [0, 1] by computing its upper and lower Darboux sums.
Step 1: For any partition of [0,1], every subinterval contains at least one rational number, so the supremum of D on each subinterval is 1. The upper Darboux sum equals the total length of the interval.
U(D,P)=i=1n1Δxi=1U(D, P) = \sum_{i=1}^{n} 1 \cdot \Delta x_i = 1
Step 2: Every subinterval also contains at least one irrational number, so the infimum of D on each subinterval is 0. The lower Darboux sum equals zero.
L(D,P)=i=1n0Δxi=0L(D, P) = \sum_{i=1}^{n} 0 \cdot \Delta x_i = 0
Step 3: Since the upper and lower Darboux integrals differ regardless of partition refinement, D fails the Riemann integrability criterion.
01D(x)dx=10=01D(x)dx\overline{\int_0^1} D(x)\,dx = 1 \neq 0 = \underline{\int_0^1} D(x)\,dx
Answer: The Dirichlet function is not Riemann integrable on [0, 1] because its upper integral is 1 and its lower integral is 0.

Why It Matters

The Dirichlet function is a cornerstone counterexample in real analysis courses. It demonstrates why the Riemann integral has limitations and motivates the development of Lebesgue integration. Understanding it sharpens your intuition about continuity, measure, and the subtle structure of the real number line.

Common Mistakes

Mistake: Assuming the Dirichlet function is continuous at irrational points because 'most' nearby values are 0.
Correction: Every neighborhood of an irrational point contains rationals where D = 1, so the limit does not exist at any point. The function is discontinuous everywhere, not just at rationals.