Let . A subset is called dense in if any real number can be arbitrarily well-approximated by elements of . For example, the rational numbers are dense in , since every real number has rational numbers that are arbitrarily close to it.
Formally, is dense in if, for any and , there is some such that .
An equivalent definition is that is dense in if, for any , there is a sequence such that
that is the big rectangle. There is subset that can be said to be dense in . This is because for any point , in this case a random point in the larger set , one could draw a circle around using a random as the radius and some element of that circle will be in .The image to the right shows this visually. There is a set
The canonical example of a dense subset of is the set of rational numbers :
The rational numbers are dense in .
Take . We may write where and . Consider the decimal expansion Setting we see that each is rational and
In fact, for any irrational number , the set is dense in . This is harder to prove than the above example, and requires clever use of the pigeonhole principle.
For any irrational , the set is dense in .
Assume . The proof when is entirely analogous.
Let denote the fractional part of . First, we claim that the set is dense in .
Choose and pick an integer such that . Divide the unit interval into subintervals, each of length . By the pigeonhole principle, some two of the numbers must be in the same subinterval, so there exist integers such that .
But , so . For any , there is some such that . We may then pick an integer such that so that . Thus, is dense in .
Now, for any , write where and . Since is dense in , there is such that . It follows that Since , we conclude is dense in .
One may define dense sets of general metric spaces similarly to how dense subsets of were defined.
Suppose is a metric space. A subset is called dense in if for every and , there is some such that .
For example, let denote the set of continuous functions . One may give the structure of a metric space by defining By the extreme value theorem, this maximum exists for any two , so the distance function is well-defined. One can easily check that satisfies the axioms of a metric space.
Let be the subset consisting of polynomial functions. The Stone-Weierstrass theorem states that is dense in . Intuitively, this means any continuous function on a closed interval is well-approximated by polynomial functions!