# Dense Set

Let \(X \subset \mathbb{R}\). A subset \(S \subset X\) is called **dense in \(X\)** if any real number can be arbitrarily well-approximated by elements of \(S\). For example, the rational numbers \(\mathbb{Q}\) are dense in \(\mathbb{R}\), since every real number has rational numbers that are arbitrarily close to it.

Formally, \(S \subset X\) is dense in \(X\) if, for any \(\epsilon > 0\) and \(x\in X\), there is some \(s\in S\) such that \(|x - s| < \epsilon\).

An equivalent definition is that \(S\) is dense in \(X\) if, for any \(x\in X\), there is a sequence \(\{x_n\} \subset S\) such that \[\lim_{n\to\infty} x_n = x.\]

The image to the right shows this visually. There is a set \(X\) that is the big rectangle. There is subset \(S\) that can be said to be dense in \(X\). This is because for any point \(x\in X\), in this case a random point \(x\) in the larger set \(X\), one could draw a circle around \(x\) using a random \(s\in S\) as the radius and some element of that circle will be in \(S\).

## Examples of Dense Sets

The canonical example of a dense subset of \(\mathbb{R}\) is the set of rational numbers \(\mathbb{Q}\):

The rational numbers \(\mathbb{Q}\) are dense in \(\mathbb{R}\).

Take \(x\in \mathbb{R}\). We may write \(x = n + r,\) where \(n \in \mathbb{Z}\) and \(0 \le r < 1\). Consider the decimal expansion \[r = 0. r_1 r_2 r_3 \cdots. \] Setting \[x_k = n + 0.r_1 r_2 \cdots r_k, \] we see that each \(x_k\) is rational and \[\lim_{k\to\infty} x_k = x.\ _\square\]

In fact, for any irrational number \(\alpha \in \mathbb{R}\), the set \[S_{\alpha} = \{a+b\alpha \, | \, a, b \in \mathbb{Z}\}\] is dense in \(\mathbb{R}\). This is harder to prove than the above example, and requires clever use of the pigeonhole principle.

For any irrational \(\alpha \in \mathbb{R}\), the set \(S_{\alpha}\) is dense in \(\mathbb{R}\).

Assume \(\alpha > 0\). The proof when \(\alpha < 0\) is entirely analogous.

Let \(\{x\}\) denote the fractional part of \(x\). First, we claim that the set \[R_{\alpha} = \big\{\{n\alpha\} \, | \, n \in \mathbb{Z}\big\}\] is dense in \([0,1]\).

Choose \(\epsilon > 0\) and pick an integer \(m\) such that \(m > \frac{1}{\epsilon}\). Divide the unit interval \([0,1]\) into \(m\) subintervals, each of length \(\frac1m\). By the pigeonhole principle, some two of the numbers \(\{\alpha\}, \{2\alpha\}, \cdots, \{m\alpha\}, \{(m+1)\alpha\}\) must be in the same subinterval, so there exist integers \(1\le i < j \le m+1\) such that \(\Big|\{i\alpha\} - \{j\alpha\}\Big| < \frac1m\).

But \(\Big|\{j\alpha\} - \{i\alpha\}\Big| = \{(j-i)\alpha\} \), so \( \{(j-i)\alpha\} < \frac1m \). For any \(y \in [0,1]\), there is some \(0\le k \le m-1\) such that \(y \in \left[\frac km, \frac{k+1}{m}\right]\). We may then pick an integer \(q\) such that \[q\{(j-i)\alpha\} = \{q(j-i) \alpha\} \in \left [ \frac{k}{m}, \frac{k+1}{m} \right], \] so that \(\Big|y - \{q(j-i)\alpha\}\Big| < \frac1m < \epsilon\). Thus, \(R_{\alpha}\) is dense in \([0,1]\).

Now, for any \(z \in \mathbb{R}\), write \(z = a + r,\) where \(a \in \mathbb{Z}\) and \(0\le r <1\). Since \(R_{\alpha}\) is dense in \([0,1]\), there is \(b \in \mathbb{N}\) such that \(\Big|r - \{b \alpha\}\Big| < \epsilon\). It follows that \[\Big|a- \lfloor b \alpha \rfloor + b\alpha - z\Big| = \Big|\{b\alpha\} - r\Big| < \epsilon.\] Since \(a- \lfloor b \alpha \rfloor + b\alpha \in S_{\alpha}\), we conclude \(S_{\alpha}\) is dense in \(\mathbb{R}\). \(_\square\)

## Dense Sets in General Metric Spaces

One may define dense sets of general metric spaces similarly to how dense subsets of \(\mathbb{R}\) were defined.

Suppose \((M, d)\) is a metric space. A subset \(S \subset M\) is called

dense in \(M\)if for every \(\epsilon > 0\) and \(x\in M\), there is some \(s\in S\) such that \(d(x, s) < \epsilon\).

For example, let \(\mathcal{C}[a,b]\) denote the set of continuous functions \(f: [a,b] \to \mathbb{R}\). One may give \(\mathcal{C}[a,b]\) the structure of a metric space by defining \[d(f,g) = \max_{x\in [a,b]} \big|f(x) - g(x)\big|.\] By the extreme value theorem, this maximum exists for any two \(f, g \in \mathcal{C}[a,b]\), so the distance function is well-defined. One can easily check that \(d\) satisfies the axioms of a metric space.

Let \(\mathcal{P} \subset \mathcal{C}[a,b]\) be the subset consisting of polynomial functions. The Stone-Weierstrass theorem states that \(\mathcal{P}\) is dense in \(\mathcal{C}[a,b]\). Intuitively, this means any continuous function on a closed interval is well-approximated by polynomial functions!