Skip to content
Tutorials Center
My learning

Topics

Lesson 8 of 37 ยท The Real Numbers

Density of the Rationals and Irrationals

Prove that between any two real numbers lie both a rational and an irrational number, and learn what dense means with a runnable search.

Between any two distinct real numbers, no matter how close, there is a fraction. There is also an irrational number. Both sets are woven through the real line, even though one is countable and the other is not. This property is called density, and it lets us approximate any real number as closely as we like by rationals, which is how computers represent reals.

Density of โ„š in โ„

Theorem. If a < b are real numbers, there is a rational q with a < q < b.

Proof. Since b - a > 0, the Archimedean property gives n โˆˆ โ„• with 1/n < b - a, that is na + 1 < nb. Let m be the smallest integer greater than na. (It exists: the integers greater than na form a set bounded below that is nonempty, and by the well-ordering of the integers it has a least element.) Then m - 1 โ‰ค na < m, so

na < m โ‰ค na + 1 < nb.

Divide by n: a < m/n < b. So q = m/n works. โˆŽ

The proof is constructive: pick a denominator n large enough that the grid spacing 1/n is smaller than the interval, then pick the first grid point above a.

Python Find a rational between two numbers

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Density of the irrationals

Theorem. If a < b, there is an irrational r with a < r < b.

Proof. Apply the previous theorem to a/โˆš2 < b/โˆš2 to get a rational q with a/โˆš2 < q < b/โˆš2. Then a < qโˆš2 < b. We may choose q โ‰  0 (apply the theorem again if needed). The number qโˆš2 is irrational: if it were a rational p, then โˆš2 = p/q would be rational, which is false. โˆŽ

So both โ„š and โ„ \ โ„š are dense in โ„: every open interval contains points of each.

Dense does not mean "equally many". โ„š is countable and the irrationals are uncountable. A countable set can still be dense, as โ„š shows.

Python An irrational between any two numbers

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Approximating a real number by rationals

Density implies that every real x is a limit of rationals: for each n, choose a rational q_n with x < q_n < x + 1/n. The decimal truncations 3, 3.1, 3.14, 3.141, ... of ฯ€ do exactly this.

A practical version: for a real x and a bound N on the denominator, which fraction p/q with q โ‰ค N is closest? Continued fractions give famous answers: 22/7 and 355/113 for ฯ€.

Python Best rational approximations to pi

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Using density in proofs

A classic application: if x โ‰ค y + ฮต for every ฮต > 0, then x โ‰ค y. Another: to show two real numbers a, b are equal, it is enough to show no rational lies strictly between them, because if a < b density would supply one.

Example. Suppose f: โ„ โ†’ โ„ satisfies f(x + y) = f(x) + f(y) and is increasing. Knowing f on the rationals determines it on all of โ„, because any real is squeezed between rationals. That is the kind of argument density makes possible.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does 'โ„š is dense in โ„' mean?

    Between any two reals there is a rational number.
  2. 2. Which tool is used to choose the denominator n in the proof of density of โ„š?

    The Archimedean property gives n with 1/n < b - a.
  3. 3. Why is qยทโˆš2 irrational when q is a nonzero rational?

    A quotient of rationals is rational, which would contradict irrationality of โˆš2.
  4. 4. โ„š is countable and dense. What does that tell you?

    Density is about position on the line, not about cardinality.

Summary

  • Between any two reals there is a rational (density of โ„š) and an irrational (density of โ„ \ โ„š).
  • The proof uses the Archimedean property to pick a fine grid 1/n.
  • Every real is a limit of rationals; decimals and continued fractions give approximations.
  • Density has nothing to do with size: โ„š is dense yet countable.

Next: Absolute Value, Intervals and Nested Intervals