Tutorials › Real Analysis › Density of the Rationals

Topology of the Real Line · Tutorial 260 of 1000

Density of the Rationals

Learn how to construct a rational number between any two distinct real numbers and use this result to understand the local abundance of the rationals.

Intermediate 10 min read

What You'll Learn

  • Use the Archimedean property to choose a denominator suited to an interval’s length
  • Prove an integer-selection lemma that locates an integer just above a real number
  • Construct a rational number strictly between any two distinct real numbers
  • Verify rational numbers in intervals with exact inequalities
  • Show that every nonempty open interval contains infinitely many rationals
  • Use density to find rational approximations to any real number

Finding a Rational Number Inside Any Interval

The previous tutorial defined density by testing whether every nonempty open interval meets a set. For the rational numbers, this means more than observing that fractions appear throughout familiar number lines: given any real numbers \(a<b\), we must construct a rational number strictly between them. The key is to choose a denominator large enough that consecutive multiples of its reciprocal are closer together than the interval is wide.

Write \(\mathbb{Q}\) for the set of rational numbers. A rational number has the form \(m/n\), where \(m\) is an integer and \(n\) is a positive integer. We will use the Archimedean property of \(\mathbb{R}\): for every real number \(x\), there is a positive integer greater than \(x\). First, we establish how to choose an integer just above a given real number.

Lemma (Integer Just Above a Real Number): For every \(x\in\mathbb{R}\), there exists an integer \(m\) such that \(x<m\leq x+1\).

Proof. By the Archimedean property, choose a positive integer \(N>|x|\). Then \(-N<x<N\), so the set \(S=\{k\in\mathbb{Z}:x<k\}\) is nonempty, since \(N\in S\). If \(k\in S\), then \(k>x>-N\), so \(k+N\) is a positive integer. Thus \(T=\{k+N:k\in S\}\) is a nonempty set of positive integers. By the well-ordering principle, \(T\) has a least element \(t\). Let \(m=t-N\), so \(m\in S\) and \(x<m\).

If \(m-1>x\), then \(m-1\in S\), and \((m-1)+N=t-1\) is a positive integer smaller than \(t\). This contradicts the choice of \(t\) as the least element of \(T\). Hence \(m-1\leq x\), which gives \(m\leq x+1\). Together, \(x<m\leq x+1\), as required. \(\square\)

The strict lower inequality and the weak upper inequality in this lemma are both useful. The integer \(m\) is strictly above \(x\), while it may be exactly one unit above \(x\). We will make the interval wide enough, after scaling, that even this possible endpoint case still produces a rational number strictly inside the original interval.

The Density Theorem

Theorem (Density of the Rationals): The set \(\mathbb{Q}\) is dense in \(\mathbb{R}\). Equivalently, whenever \(a,b\in\mathbb{R}\) and \(a<b\), there is a rational number \(q\) such that \(a<q<b\).

Proof. Let \(a<b\), and set \(L=b-a\), so \(L>0\). By the Archimedean property, choose a positive integer \(n\) such that \(n>1/L\). Since \(n\) and \(L\) are positive, this implies \(nL>1\), or equivalently \(1/n<b-a\).

Apply the Integer Just Above a Real Number Lemma to \(x=na\). It gives an integer \(m\) satisfying

$$ na<m\leq na+1. $$

Because \(n>0\), dividing by \(n\) preserves the inequalities. Therefore

$$ a<\frac{m}{n}\leq a+\frac{1}{n}<a+(b-a)=b. $$

The number \(q=m/n\) is rational because \(m\in\mathbb{Z}\) and \(n\) is a positive integer. The displayed inequalities show \(a<q<b\). Thus every nonempty open interval \((a,b)\) contains a rational number, so \(\mathbb{Q}\) is dense by the definition of density. \(\square\)

The proof has a useful geometric interpretation. The numbers \(m/n\), as \(m\) ranges over the integers, are spaced a distance \(1/n\) apart. Choosing \(n\) so that \(1/n<b-a\) makes this spacing smaller than the interval’s length. The integer-selection lemma then supplies a multiple \(m/n\) that lies after the left endpoint without reaching the right endpoint.

Worked Example: A Rational Between Two Square Roots

Find a rational number in \((\sqrt{2},3/2)\). Consider \(q=10/7\). To check the left inequality, both \(\sqrt{2}\) and \(10/7\) are positive, and

$$ 2<\frac{100}{49} $$

because \(98<100\). Taking positive square roots gives \(\sqrt{2}<10/7\). For the right inequality, the denominators are positive and

$$ \frac{10}{7}<\frac{3}{2} \quad\Longleftrightarrow\quad 20<21. $$

Hence \(\sqrt{2}<10/7<3/2\). This verifies directly that \(10/7\) is a rational in the stated interval.

Worked Example: Using a Convenient Common Denominator

Consider the interval \((5/12,7/12)\). The rational number \(1/2\) lies in this interval, since \(1/2=6/12\) and

$$ \frac{5}{12}<\frac{6}{12}<\frac{7}{12}. $$

This simple example illustrates the kind of comparison used in the general proof: expressing the endpoints and the proposed rational with a common denominator makes both strict inequalities explicit.

Rational Approximations to Real Numbers

Density can be applied to intervals centered at a point. Given any real number \(x\) and any tolerance \(\varepsilon>0\), the interval \((x-\varepsilon,x+\varepsilon)\) is nonempty and open. The Density of the Rationals Theorem therefore gives a rational number \(q\) in that interval. Membership means exactly that \(q\) is within \(\varepsilon\) of \(x\).

Corollary (Rational Approximation): For every \(x\in\mathbb{R}\) and every \(\varepsilon>0\), there exists \(q\in\mathbb{Q}\) such that \(|x-q|<\varepsilon\).

Proof. Fix \(x\in\mathbb{R}\) and \(\varepsilon>0\). Since \(x-\varepsilon<x+\varepsilon\), the Density of the Rationals Theorem gives \(q\in\mathbb{Q}\) with \(x-\varepsilon<q<x+\varepsilon\). Subtracting \(x\) gives \(-\varepsilon<q-x<\varepsilon\), which is equivalent to \(|q-x|<\varepsilon\). \(\square\)

Worked Example: Approximating the Square Root of Three

We can check that \(17/10\) is within \(1/10\) of \(\sqrt{3}\) without using decimal approximations. First, \(8/5<\sqrt{3}\), because both sides are positive and

$$ \left(\frac{8}{5}\right)^2=\frac{64}{25}<3. $$

Also, \(\sqrt{3}<9/5\), because both sides are positive and

$$ 3<\left(\frac{9}{5}\right)^2=\frac{81}{25}. $$

Since \(8/5=16/10\) and \(9/5=18/10\), these bounds give

$$ \frac{16}{10}<\sqrt{3}<\frac{18}{10}. $$

Subtracting \(17/10\) shows that \(-1/10<\sqrt{3}-17/10<1/10\). Therefore \(\left|\sqrt{3}-17/10\right|<1/10\), and \(17/10\) is the required rational approximation.

In particular, the Sequential Characterization of Density from “Dense Sets” applies to \(\mathbb{Q}\): for every real \(x\), there is a sequence of rational numbers converging to \(x\). One can see the construction directly by applying the corollary with \(\varepsilon=1/n\) for each positive integer \(n\), and choosing a rational \(q_n\) with \(|q_n-x|<1/n\). Since \(1/n\) tends to zero, these inequalities imply \(q_n\to x\).

Every Interval Contains Infinitely Many Rationals

The density theorem guarantees at least one rational in each nonempty open interval. In fact, there are infinitely many. To prove this, it is enough to place infinitely many pairwise disjoint nonempty open intervals inside the original interval, then use density to find a rational in each one.

Theorem (Infinitely Many Rationals in Every Open Interval): Every nonempty open interval in \(\mathbb{R}\) contains infinitely many distinct rational numbers.

Proof. Fix \(a<b\), and write \(L=b-a>0\). For each positive integer \(j\), define

$$ I_j=\left(a+\frac{L}{2^{j+1}},\,a+\frac{L}{2^j}\right). $$

Both endpoints of \(I_j\) are strictly between \(a\) and \(b\): the fractions \(1/2^{j+1}\) and \(1/2^j\) are positive and less than \(1\). The left endpoint is smaller than the right endpoint, so \(I_j\) is nonempty and \(I_j\subseteq(a,b)\). Moreover, the right endpoint of \(I_{j+1}\) is \(a+L/2^{j+1}\), which is the left endpoint of \(I_j\). Since both intervals are open, they do not intersect. It follows that the intervals \(I_j\) are pairwise disjoint.

By the Density of the Rationals Theorem, for each \(j\) there is a rational \(q_j\in I_j\). If \(j\neq k\), then \(I_j\cap I_k=\varnothing\), so \(q_j\neq q_k\). Thus the original interval contains the infinitely many distinct rational numbers \(q_1,q_2,\ldots\). \(\square\)

This theorem strengthens density, but the two statements are not identical: density asks whether every interval contains at least one point, whereas the stronger result establishes infinitely many. The disjoint-interval argument is a useful general method whenever a dense set is already known and infinitely many distinct members are needed.

What Density Does—and Does Not—Say

Density is an approximation property, not an equality of sets. It does not say that every real number is rational. Instead, it says that no matter which real number is chosen, rational numbers can be found as close to it as desired. The Rational Approximation Corollary makes this distinction precise: the rational number may depend on both the target \(x\) and the tolerance \(\varepsilon\).

A common pitfall is to choose a denominator that is large without connecting it to the length of the interval. In the proof, the essential requirement is \(1/n<b-a\). This strict inequality ensures that even if the selected integer satisfies \(m=na+1\), the resulting rational \(m/n\) remains strictly below \(b\). The integer lemma allows equality at its upper bound, so this final strict comparison must not be omitted.

The Density and Closure Theorem from “Dense Sets” also gives \(\overline{\mathbb{Q}}=\mathbb{R}\). Thus the closure formulation and the interval construction express the same global fact in different ways: the interval proof constructs a rational directly, while the closure statement records that every real point is approximable by rationals. When a problem asks for an explicit rational in a particular interval, exact inequalities such as those in the worked examples provide the necessary verification.

Check Your Understanding

Use the proof and consequences above to answer the following questions.

  1. Why is the condition \(n>1/(b-a)\) enough to ensure that \(1/n<b-a\)?
  2. In the density proof, what two inequalities does the integer \(m\) satisfy when the lemma is applied to \(na\)?
  3. Why does the possibility \(m=na+1\) still lead to a rational strictly below \(b\)?
  4. How does rational approximation follow by applying density to an interval centered at a real number?
  5. Why do pairwise disjoint intervals inside \((a,b)\) yield distinct rational numbers when density is applied to each interval?