Thomae's Function

The popcorn function f(p/q)=1/qf(p/q) = 1/q (reduced), f(x)=0f(x) = 0 (irrational): continuous at every irrational, discontinuous at every rational. Given ε\varepsilon, only finitely many dots reach height ε\varepsilon — so near an irrational a δ\delta can always be found.

f(x)={1/qx=p/q in lowest terms0x∉Qf(x) = \begin{cases} 1/q & x = p/q \text{ in lowest terms} \\ 0 & x \notin \mathbb{Q} \end{cases}
{x:f(x)≥ε}={p/q:q≤1/ε} finite\{x : f(x) \ge \varepsilon\} = \{p/q : q \le 1/\varepsilon\} \text{ finite}

Examples & Exercises

Prove completely that Thomae's function ff (f(p/q)=1/qf(p/q) = 1/q in lowest terms, f=0f = 0 at irrationals) is discontinuous at every rational x0x_0.

x0=pq (lowest terms)⇒f(x0)=1q>0,ε=12qx_0 = \frac{p}{q}\ \text{(lowest terms)} \Rightarrow f(x_0) = \frac{1}{q} > 0, \quad \varepsilon = \frac{1}{2q}
View centered at the rational x0=1/2x_0 = 1/2: f(1/2)=1/2f(1/2) = 1/2, yet irrationals with f=0f = 0 sit arbitrarily close, so no δ\delta works for ε=1/4\varepsilon = 1/4.
Show proof
  1. Write x0=p/qx_0 = p/q in lowest terms, so f(x0)=1/q>0f(x_0) = 1/q > 0. Set ε=1/(2q)>0\varepsilon = 1/(2q) > 0. By density of the irrationals, for every δ>0\delta > 0 the interval (x0−δ,x0+δ)(x_0 - \delta, x_0 + \delta) contains an irrational xx.
  2. At an irrational xx, f(x)=0f(x) = 0, so ∣f(x)−f(x0)∣=1/q>1/(2q)=ε|f(x) - f(x_0)| = 1/q > 1/(2q) = \varepsilon. That is, for every δ>0\delta > 0 there is an xx with ∣x−x0∣<δ|x - x_0| < \delta but ∣f(x)−f(x0)∣≥ε|f(x) - f(x_0)| \ge \varepsilon; by the ε\varepsilon-δ\delta definition, ff is not continuous at x0x_0.
  3. Since x0x_0 was an arbitrary rational, Thomae's function is discontinuous at every rational. In the scene, centering on a rational (e.g. 1/21/2) gives δ=0\delta = 0, exhibiting this argument directly.

Prove completely, by an ε\varepsilon-δ\delta argument, that Thomae's function is continuous at every irrational x0x_0.

Sε={x∈[0,1]:f(x)≥ε}={pq:q≤1ε} finiteS_\varepsilon = \left\{x \in [0,1] : f(x) \ge \varepsilon\right\} = \left\{\frac{p}{q} : q \le \frac{1}{\varepsilon}\right\}\ \text{finite}
View centered at the irrational x0≈0.618x_0 \approx 0.618: only finitely many dots (those with q≤10q \le 10) reach height ε=0.1\varepsilon = 0.1, and δ\delta is the distance to the nearest one.
Show proof
  1. Let x0x_0 be irrational and ε>0\varepsilon > 0 arbitrary. Consider Sε={x∈[0,1]:f(x)≥ε}S_\varepsilon = \{x \in [0,1] : f(x) \ge \varepsilon\}. By the definition of ff, members of SεS_\varepsilon are only lowest-terms fractions p/qp/q with 1/q≥ε1/q \ge \varepsilon, i.e. q≤1/εq \le 1/\varepsilon; hence SεS_\varepsilon is a finite set.
  2. Since x0x_0 is irrational, x0∉Sεx_0 \notin S_\varepsilon. Thus δ=min⁡x∈Sε∣x−x0∣\delta = \min_{x \in S_\varepsilon} |x - x_0|, the minimum of finitely many positive numbers, is strictly positive. If ∣x−x0∣<δ|x - x_0| < \delta then xx is at distance at least δ\delta from every member of SεS_\varepsilon, so x∉Sεx \notin S_\varepsilon — i.e. f(x)<εf(x) < \varepsilon (for x=x0x = x_0 this is trivial since f(x0)=0<εf(x_0) = 0 < \varepsilon).
  3. Since ∣f(x)−f(x0)∣=∣f(x)−0∣=f(x)<ε|f(x) - f(x_0)| = |f(x) - 0| = f(x) < \varepsilon, ff is continuous at x0x_0. As x0x_0 was an arbitrary irrational, Thomae's function is continuous at every irrational — the δ\delta shown in the scene is exactly this minimum.

Show that Thomae's function is a pointwise limit of continuous functions — i.e. prove completely that it is of Baire class 1.

fn(x)=max⁡p/q lowest terms, q≤nmax⁡(0,1q−n∣x−pq∣)→f(x) ∀xf_n(x) = \max_{\substack{p/q\ \text{lowest terms},\ q \le n}} \max\left(0, \frac{1}{q} - n\left|x - \frac{p}{q}\right|\right) \to f(x)\ \forall x
Q=30Q = 30, ε=0.05\varepsilon = 0.05: a pointwise limit of continuous tent functions draws these popcorn dots — a Baire-1 function must have a dense set of continuity points, and Thomae's is the irrationals (a dense GδG_\delta).
Show proof
  1. For each n≥1n \ge 1 let Sn={p/q:1≤q≤n, gcd⁡(p,q)=1}S_n = \{p/q : 1 \le q \le n,\ \gcd(p,q) = 1\} (a finite set) and define fn(x)=max⁡r∈Snmax⁡(0,1/q(r)−n∣x−r∣)f_n(x) = \max_{r \in S_n} \max(0, 1/q(r) - n|x - r|), where q(r)q(r) is the denominator of r=p/qr = p/q. Each tent x↦max⁡(0,1/q−n∣x−r∣)x \mapsto \max(0, 1/q - n|x - r|) is continuous, and a finite maximum of continuous functions is continuous, so each fnf_n is continuous.
  2. Let x=a/bx = a/b in lowest terms. For n≥bn \ge b, the tent at r=xr = x itself gives the value 1/b1/b, while for any other r′=p/q≠xr' = p/q \ne x with q≤nq \le n we have ∣x−r′∣≥1/(bq)|x - r'| \ge 1/(bq) (distinct rationals with denominators b,qb, q differ by at least 1/(bq)1/(bq)), so n∣x−r′∣≥n/(bq)≥1/qn|x - r'| \ge n/(bq) \ge 1/q — the tent value is 0. Hence fn(x)=1/b=f(x)f_n(x) = 1/b = f(x) for n≥bn \ge b.
  3. If xx is irrational, f(x)=0f(x) = 0. Fix M≥1M \ge 1: tents with denominator q≤Mq \le M all vanish for large nn (there are only finitely many rationals with denominator ≤M\le M, each at positive distance from the irrational xx), and tents with q>Mq > M are worth at most 1/q<1/M1/q < 1/M. Hence lim sup⁡n→∞fn(x)≤1/M\limsup_{n \to \infty} f_n(x) \le 1/M; since MM is arbitrary, fn(x)→0=f(x)f_n(x) \to 0 = f(x). So fn→ff_n \to f at every xx: Thomae's function is Baire class 1.

3. Continuity