Density of the Rationals

Every open interval (x,y)(x, y) contains a rational: with n=⌊1/(y−x)⌋+1n = \lfloor 1/(y-x) \rfloor + 1 and m=⌊nx⌋+1m = \lfloor nx \rfloor + 1, x<m/n<yx < m/n < y. Watch the rational ticks inside the interval multiply as the denominator cap grows.

n=⌊1y−x⌋+1,m=⌊nx⌋+1n = \left\lfloor\frac{1}{y-x}\right\rfloor + 1,\quad m = \lfloor nx \rfloor + 1
x<mn<yx < \frac{m}{n} < y
z=r+(s−r)22 is irrationalz = r + (s-r)\frac{\sqrt{2}}{2}\ \text{is irrational}

Examples & Exercises

Prove completely, from the Archimedean property, that for every real xx there is an integer nn with n≤x<n+1n \le x < n+1 (Tao, Proposition 4.4.1).

∀ x∈R ∃ n∈Z: n≤x<n+1\forall\, x \in \mathbb{R}\ \exists\, n \in \mathbb{Z}:\ n \le x < n+1
Interval (1,2)(1, 2): n=⌊1/(2−1)⌋+1=2n = \lfloor 1/(2-1) \rfloor + 1 = 2, m=⌊2⋅1⌋+1=3m = \lfloor 2 \cdot 1 \rfloor + 1 = 3, so q=3/2=1.5q = 3/2 = 1.5 lands inside. The proof below shows this recipe always works.
Show proof
  1. Let S={k∈Z:k≤x}S = \{k \in \mathbb{Z} : k \le x\}. By the Archimedean property there is a natural number K>−xK > -x; then −K<x-K < x, so −K∈S-K \in S — SS is nonempty and bounded above by xx.
  2. A nonempty set of integers bounded above has a maximum: pick an integer M>xM > x (Archimedean); then S′′={M−s:s∈S}S'' = \{M - s : s \in S\} is a nonempty set of nonnegative integers, so by well-ordering it has a least element M−nM - n with n∈Sn \in S. Every s∈Ss \in S satisfies M−s≥M−nM - s \ge M - n, i.e. s≤ns \le n, so n=max⁡Sn = \max S.
  3. Since n∈Sn \in S, n≤xn \le x. Also n+1>xn + 1 > x: otherwise n+1≤xn + 1 \le x would put n+1∈Sn + 1 \in S, contradicting the maximality of nn. Hence n≤x<n+1n \le x < n+1 — every real sits exactly between two consecutive integer marks.

Prove completely that for reals x<yx < y there is a rational qq with x<q<yx < q < y — the rationals are dense in the reals (Tao, Proposition 4.4.3).

x<y⇒∃ q∈Q: x<q<yx < y \Rightarrow \exists\, q \in \mathbb{Q}:\ x < q < y
n=⌊1y−x⌋+1,m=⌊nx⌋+1,q=mnn = \left\lfloor\frac{1}{y-x}\right\rfloor + 1,\quad m = \lfloor nx \rfloor + 1,\quad q = \frac{m}{n}
Interval (1,2)(1, 2): taking n=2n = 2 with 1/n<y−x1/n < y - x, one of the 1/21/2-spaced marks …,1,3/2,2,…\dots, 1, 3/2, 2, \dots — namely 3/23/2 — falls inside the interval: the proof's recipe executed live.
Show proof
  1. Since y−x>0y - x > 0, the Archimedean property gives a natural number nn larger than 1y−x\frac{1}{y-x} — i.e. 1n<y−x\frac{1}{n} < y - x. The model computes such an nn directly as n=⌊1y−x⌋+1n = \left\lfloor\frac{1}{y-x}\right\rfloor + 1.
  2. Applying problem 1 to nxnx gives an integer mm with m−1≤nx<mm - 1 \le nx < m (the model computes m=⌊nx⌋+1m = \lfloor nx \rfloor + 1). Put q=m/nq = m/n; from m>nxm > nx we get mn>nxn=x\frac{m}{n} > \frac{nx}{n} = x.
  3. Also m<nx+1m < nx + 1, and 1n<y−x\frac{1}{n} < y - x is equivalent to 1<n(y−x)1 < n(y - x), so nx+1<nx+n(y−x)=nynx + 1 < nx + n(y - x) = ny. Hence m<nym < ny, i.e. mn<y\frac{m}{n} < y. Together: x<mn<yx < \frac{m}{n} < y — the desired rational q=m/nq = m/n is found.
  4. The key idea: once the marks are spaced finer than the interval (1n<y−x\frac{1}{n} < y - x), no mark can jump clean over it. However narrow the interval (try the (0,0.1)(0, 0.1) and (−3.5,−3.4)(-3.5, -3.4) presets), finer marks always work — there are no exceptions.

Prove the irrationals are dense too: if x<yx < y there is an irrational zz with x<z<yx < z < y (hint: pick rationals r<sr < s inside (x,y)(x, y) and use z=r+(s−r)22z = r + (s-r)\frac{\sqrt{2}}{2}).

z=r+(s−r)22∈(x,y),z∉Qz = r + (s-r)\frac{\sqrt{2}}{2} \in (x, y),\qquad z \notin \mathbb{Q}
Interval (1,2)(1, 2): with rationals r=3/2r = 3/2, s=7/4s = 7/4, z=32+14⋅22≈1.677z = \frac{3}{2} + \frac{1}{4}\cdot\frac{\sqrt{2}}{2} \approx 1.677 is an irrational inside (1,2)(1, 2) — an irrational always squeezes between rational marks.
Show proof
  1. By problem 2 there are rationals r<sr < s inside (x,y)(x, y). Put z=r+(s−r)22z = r + (s - r)\frac{\sqrt{2}}{2}. Since 1<2<41 < 2 < 4 and squaring is strictly increasing on [0,∞)[0, \infty) (problem 1 of the sqrt2-irrational scene, plus the n-th root scene), 1<2<21 < \sqrt{2} < 2 — hence 0<22<10 < \frac{\sqrt{2}}{2} < 1.
  2. Since s−r>0s - r > 0, 0<(s−r)22<s−r0 < (s-r)\frac{\sqrt{2}}{2} < s - r; adding rr gives r<z<sr < z < s. With x<rx < r and s<ys < y, x<z<yx < z < y — zz lies in the interval.
  3. Now zz is irrational: if it were rational, 2=2(z−r)s−r\sqrt{2} = \frac{2(z - r)}{s - r} would be rational too (the right side is arithmetic on rationals with nonzero denominator) — contradicting Proposition 4.4.4 that 2\sqrt{2} is irrational (problem 1 of the sqrt2-irrational scene). Hence zz is irrational with x<z<yx < z < y.
  4. Corollary: every open interval of the real line contains both rationals and irrationals. Density of the rationals does not mean "almost all" reals are rational — quite the opposite is true (the countability scene).

1. Number Systems