The Dirichlet Function

A function that is 1 on the rationals and 0 on the irrationals. It is the canonical failure of the Riemann integral.

Every tiny interval holds rationals and irrationals together. So the upper sum stays pinned at 1. The lower sum stays at 0 and the gap never closes.

For example, mix black and white ⚽ balls as finely as you like, and every scoop still holds both colors. No single height can be assigned.

U(f,P)=1, L(f,P)=0 ∀PU(f,P) = 1,\ L(f,P) = 0\ \forall P
f=1Qf = \mathbf{1}_{\mathbb{Q}}

Examples & Exercises

Let f=1Qf = \mathbf{1}_{\mathbb{Q}} be the Dirichlet function on [0,1][0, 1].

Using that every subinterval of [0,1][0, 1] contains a rational, prove completely that U(f,P)=1U(f, P) = 1 for every partition PP.

U(f,P)=∑i=1nMi Δxi=1∀PU(f, P) = \sum_{i=1}^{n} M_i\,\Delta x_i = 1 \quad \forall P
n=8n = 8: all 8 subintervals carry an upper rectangle (light red, height 1) — U(f,P8)=8⋅18=1U(f, P_8) = 8 \cdot \frac18 = 1.
Show proof
  1. First, density of Q\mathbb{Q}: if u<vu < v then (u,v)(u, v) contains a rational. Pick N∈NN \in \mathbb{N} with 1N<v−u\frac1N < v - u (Archimedean property) and set m=⌊Nu⌋+1m = \lfloor Nu \rfloor + 1; then mN−u=⌊Nu⌋+1−NuN≤1N<v−u\frac{m}{N} - u = \frac{\lfloor Nu \rfloor + 1 - Nu}{N} \le \frac1N < v - u, so u<mN<vu < \frac{m}{N} < v.

  2. Take a partition P={x0<x1<⋯<xn}P = \{x_0 < x_1 < \cdots < x_n\}.

    Each subinterval [xi−1,xi][x_{i-1}, x_i] contains a rational rir_i by the above, so Mi=sup⁡[xi−1,xi]f≥f(ri)=1M_i = \sup_{[x_{i-1}, x_i]} f \ge f(r_i) = 1.

    But f≤1f \le 1 always, so Mi=1M_i = 1.

  3. Hence U(f,P)=∑i=1nMi Δxi=∑i=1n1⋅(xi−xi−1)=xn−x0=1U(f, P) = \sum_{i=1}^{n} M_i\,\Delta x_i = \sum_{i=1}^{n} 1 \cdot (x_i - x_{i-1}) = x_n - x_0 = 1. However the partition is chosen, the upper sum is always 11 — the red dots (rationals) sit in every interval.

Using that every subinterval of [0,1][0, 1] contains an irrational, prove completely that L(f,P)=0L(f, P) = 0 for every partition PP.

L(f,P)=∑i=1nmi Δxi=0∀PL(f, P) = \sum_{i=1}^{n} m_i\,\Delta x_i = 0 \quad \forall P
n=8n = 8: the lower bars (blue) draw as thin zero-height lines — L(f,P8)=8⋅0=0L(f, P_8) = 8 \cdot 0 = 0.
Show proof
  1. Irrationals are dense too: if u<vu < v then (u,v)(u, v) contains an irrational. Density of Q\mathbb{Q} gives a rational qq in (u−2, v−2)(u - \sqrt{2},\, v - \sqrt{2}), and then q+2q + \sqrt{2} is an irrational in (u,v)(u, v) (since 2\sqrt{2} is irrational, rational ++ irrational is irrational).

  2. For a partition P={x0<⋯<xn}P = \{x_0 < \cdots < x_n\}, each subinterval [xi−1,xi][x_{i-1}, x_i] contains an irrational sis_i, so mi=inf⁡[xi−1,xi]f≤f(si)=0m_i = \inf_{[x_{i-1}, x_i]} f \le f(s_i) = 0. Since f≥0f \ge 0, mi=0m_i = 0.

  3. Hence L(f,P)=∑i=1n0⋅Δxi=0L(f, P) = \sum_{i=1}^{n} 0 \cdot \Delta x_i = 0. Together with the previous problem, U(f,P)−L(f,P)=1U(f, P) - L(f, P) = 1 for every partition — the gap never closes, so ff is not Riemann integrable.

Prove completely, using sequences, that the Dirichlet function f=1Qf = \mathbf{1}_{\mathbb{Q}} is discontinuous at every point of [0,1][0, 1].

rk→x, f(rk)=1sk→x, f(sk)=0r_k \to x,\ f(r_k) = 1 \qquad s_k \to x,\ f(s_k) = 0
n=8n = 8: red dots (rationals, f=1f = 1) alternate with the gaps between them (irrationals, f=0f = 0) in every interval — at no point do the nearby function values settle on one number.
Show proof
  1. Fix any x∈[0,1]x \in [0, 1].

    By density of rationals and irrationals, for each k≥1k \ge 1 we can pick a rational rkr_k and an irrational sks_k in (x−1k, x+1k)∩[0,1](x - \tfrac1k,\, x + \tfrac1k) \cap [0, 1].

    Since ∣rk−x∣<1k|r_k - x| < \frac1k and ∣sk−x∣<1k|s_k - x| < \frac1k, we have rk→xr_k \to x and sk→xs_k \to x.

  2. But f(rk)=1f(r_k) = 1, so f(rk)→1f(r_k) \to 1, and f(sk)=0f(s_k) = 0, so f(sk)→0f(s_k) \to 0. If ff were continuous at xx, sequential continuity would force both limits to equal f(x)f(x) — impossible since 1≠01 \ne 0.

  3. Hence ff is discontinuous at every point of [0,1][0, 1] — "too discontinuous" for the Riemann integral. The Lebesgue integral instead uses that the rationals have measure 00 to get ∫f=0\int f = 0 (see the Lebesgue scene).

11. Integration