Approximating Every Point of a Space
The previous tutorial studied limit points: points that every ball approaches from within a set, but not necessarily at the center itself. Density asks a related question on a larger scale. A subset is dense when its points come arbitrarily close to every point of the ambient space. The point being approximated may belong to the subset, or it may lie outside it.
Throughout, \((X,d)\) is a metric space and \(D\subseteq X\). The ambient space is part of the question: a set may be dense in one metric space and not dense in a larger one.
The definition says that no point of \(X\) is separated from \(D\) by a ball. It does not require \(D=X\), and it does not require a point \(x\in X\) to belong to \(D\) in order for points of \(D\) to approximate \(x\). Density is a statement about how a set is distributed in its ambient space, not about its size in a set-theoretic sense.
Ball and Open-Set Tests for Density
Recall that \(x\in\overline{D}\) exactly when every ball centered at \(x\) meets \(D\). Applying this closure criterion at every point gives a direct test for density. The same idea can be expressed using arbitrary nonempty open sets.
- \(D\) is dense in \(X\).
- For every \(x\in X\) and every \(r>0\), \(B_r(x)\cap D\ne\varnothing\).
- Every nonempty open subset of \(X\) meets \(D\).
Proof. By the definition of density, \(D\) is dense in \(X\) exactly when every \(x\in X\) belongs to \(\overline{D}\). By the definition of closure, this holds exactly when every ball \(B_r(x)\), for \(r>0\), meets \(D\). Thus the first two conditions are equivalent.
Suppose the ball condition holds, and let \(U\subseteq X\) be nonempty and open. Choose \(x\in U\). Since \(U\) is open, there is an \(r>0\) such that \(B_r(x)\subseteq U\). The ball condition gives a point of \(D\cap B_r(x)\), so \(D\cap U\ne\varnothing\). Conversely, suppose every nonempty open set meets \(D\). Each ball \(B_r(x)\) is a nonempty open set, so it meets \(D\). This proves all three conditions equivalent. If \(X\) is empty, all three conditions hold vacuously, and \(\overline{D}=X\) as well. \(\square\)
The open-set test is often the most convenient way to prove that a set is not dense. It is enough to find one nonempty open region that misses the set. To prove density, however, one must show that every such region is met, or use one of the equivalent tests.
Worked Example: The Rational Numbers Are Dense in the Real Line
We show that \(\mathbb{Q}\) is dense in \(\mathbb{R}\) with the usual metric. Let \(x\in\mathbb{R}\), and let \(r>0\). By the Archimedean property, choose a positive integer \(n\) such that \(1/n<r\). There is an integer \(m\) with \[ m\leq nx<m+1. \] Set \(q=m/n\), which is rational. Dividing the inequalities by \(n>0\) gives \[ q\leq x<q+\frac1n. \] Consequently, \(0\leq x-q<1/n<r\), so \(|x-q|<r\). Thus \(q\in B_r(x)\cap\mathbb{Q}\). Since \(x\) and \(r\) were arbitrary, the ball test shows that \(\mathbb{Q}\) is dense in \(\mathbb{R}\).
This argument also shows how a density proof works in practice: start with an arbitrary target and an arbitrary tolerance, then construct a point of the proposed dense set within that tolerance.
Density and Approximating Sequences
In a metric space, density can also be described using sequences. The Sequential Characterization of Closure from earlier in this course says that \(x\in\overline{D}\) exactly when some sequence of points of \(D\) converges to \(x\). Applying that result point by point gives the following useful formulation.
Proof. Suppose \(D\) is dense in \(X\), and fix \(x\in X\). For each positive integer \(n\), the ball \(B_{1/n}(x)\) meets \(D\). Choose \(d_n\in D\cap B_{1/n}(x)\). Then \(d(d_n,x)<1/n\). Given \(\varepsilon>0\), choose \(N\) so that \(1/N<\varepsilon\). For \(n\geq N\), \[ d(d_n,x)<\frac1n\leq\frac1N<\varepsilon. \] Therefore \(d_n\to x\).
Conversely, suppose that for every \(x\in X\) there is a sequence \((d_n)\) in \(D\) converging to \(x\). By the Sequential Characterization of Closure, \(x\in\overline{D}\) for every \(x\in X\). Hence \(\overline{D}=X\), so \(D\) is dense. \(\square\)
There is no requirement that the approximating sequence have distinct terms. If \(x\in D\), the constant sequence \(d_n=x\) is a valid sequence converging to \(x\). Requiring distinct terms would instead bring in a limit-point condition, which is stronger in some cases and is not part of the definition of density.
Worked Example: The Irrational Numbers Are Dense in the Real Line
Fix \(x\in\mathbb{R}\) and \(r>0\). Since the rationals are dense in \(\mathbb{R}\), choose \(q\in\mathbb{Q}\) such that \[ \left|q-(x-\sqrt{2})\right|<r. \] Let \(y=q+\sqrt{2}\). The number \(y\) is irrational: if it were rational, then \(y-q=\sqrt{2}\) would be rational, which is false. Moreover, \[ |y-x|=|q+\sqrt{2}-x|=\left|q-(x-\sqrt{2})\right|<r. \] Thus every ball around every real \(x\) contains an irrational number. By the ball test, the irrationals are dense in \(\mathbb{R}\).
This proof uses density of the rationals to establish density of a different set. The target is shifted by \(\sqrt{2}\), and the same approximation error is preserved by the shift.
Density in the Plane and in Discrete Spaces
Worked Example: Rational Coordinate Pairs Are Dense in the Plane
Let \(D=\mathbb{Q}\times\mathbb{Q}\subseteq\mathbb{R}^2\), with the Euclidean metric. Fix \((x_1,x_2)\in\mathbb{R}^2\) and \(r>0\). By density of \(\mathbb{Q}\) in \(\mathbb{R}\), choose \(q_1,q_2\in\mathbb{Q}\) such that \[ |x_1-q_1|<\frac r2 \qquad\text{and}\qquad |x_2-q_2|<\frac r2. \] Then \((q_1,q_2)\in D\), and its Euclidean distance to \((x_1,x_2)\) satisfies \[ d_2\big((x_1,x_2),(q_1,q_2)\big) =\sqrt{(x_1-q_1)^2+(x_2-q_2)^2} <\sqrt{\frac{r^2}{4}+\frac{r^2}{4}} =\frac{r}{\sqrt{2}} <r. \] Every ball in \(\mathbb{R}^2\) therefore meets \(D\), so \(\mathbb{Q}\times\mathbb{Q}\) is dense in the plane.
The coordinate errors need not each be smaller than \(r\); that alone would not guarantee Euclidean distance less than \(r\). Choosing each error less than \(r/2\) makes the displayed distance estimate valid.
Worked Example: Dense Subsets of a Discrete Metric Space
Let \(X\) be nonempty with the discrete metric \(\delta\), where \(\delta(x,y)=1\) for \(x\ne y\) and \(\delta(x,x)=0\). We show that a subset \(D\subseteq X\) is dense in \(X\) exactly when \(D=X\).
If \(D=X\), then \(\overline{D}=X\), so \(D\) is dense. Conversely, suppose \(D\) is dense, and take any \(x\in X\). The ball \(B_{1/2}(x)\) is \(\{x\}\), because \(\delta(x,y)<1/2\) holds exactly when \(y=x\). The ball test for density implies \(B_{1/2}(x)\cap D\ne\varnothing\), so \(x\in D\). This holds for every \(x\in X\), proving \(D=X\).
Thus the rational numbers are dense in the usual metric on \(\mathbb{R}\), but the same underlying set cannot be dense in \(\mathbb{R}\) with the discrete metric. Density depends on the metric as well as on the set.
Density Inside an Open Region
A dense set continues to provide approximations when attention is restricted to an open region. More precisely, if \(D\) is dense in \(X\) and \(U\) is open in \(X\), then \(D\cap U\) is dense in \(U\), using the restricted metric on \(U\). Openness is important here: it ensures that a point of \(U\) has small ambient balls lying entirely within \(U\).
Proof. Suppose first that \(U\ne\varnothing\). Fix \(x\in U\) and \(r>0\). Since \(U\) is open, there is an \(s>0\) such that \(B_s(x)\subseteq U\). Let \(t=\min\{r,s\}\), which is positive. Since \(D\) is dense in \(X\), the ball \(B_t(x)\) meets \(D\); choose \(d\in B_t(x)\cap D\). Because \(t\leq s\), we have \(d\in B_s(x)\subseteq U\), and because \(t\leq r\), we have \(d\in B_r(x)\). Therefore \(d\in D\cap U\) and \(d(x,d)<r\). Every ball in the restricted metric on \(U\), centered at any \(x\in U\), meets \(D\cap U\). The ball test within \(U\) proves that \(D\cap U\) is dense in \(U\). \(\square\)
The theorem does not say that \(D\cap A\) is dense in every subset \(A\) of \(X\). For example, a dense set may fail to contain a particular point of \(A\), even when \(A\) consists of that single point. The open-set hypothesis supplies the local room needed to find approximating points while remaining inside the region.
What Density Does—and Does Not—Say
Density is a strong approximation property, but it should not be confused with equality or with the presence of limit points at every point. For instance, \(\mathbb{Q}\) is a proper subset of \(\mathbb{R}\), yet it is dense in the usual metric. Conversely, in a discrete metric space no proper subset is dense. These examples show why the metric and ambient space must always be specified.
Also, a dense set need not be closed. The closure of a dense set is the whole ambient space, so a dense set is closed only when it equals that space. This follows from the Closure Is the Smallest Closed Superset result from earlier in this course: a closed set equals its closure. Density therefore describes how closely a set fills the space, not whether it includes all its limiting points.
Check Your Understanding
Use the definitions and results in this tutorial to answer the following questions.
- State the ball-intersection condition equivalent to \(D\) being dense in \(X\).
- Why does a nonempty open set disjoint from \(D\) show that \(D\) is not dense?
- How can a sequence from a dense set be chosen to converge to a specified point \(x\in X\)?
- Why does approximating both coordinates within \(r/2\) ensure a Euclidean error less than \(r\) in the plane?
- Why must a dense subset of a discrete metric space equal the whole space?
- Where does openness enter the proof that \(D\cap U\) is dense in an open subset \(U\)?