TITLE: Intuition for dense sets. (Real analysis)
QUESTION [13 upvotes]: I have been having problems with dense sets as my lecturer didn't really develop an intuition for dense sets in my class. So can any of you please help me with that? And can you please tell me (the general case) how I should go about proving that a set is dense in R.

REPLY [16 votes]: A set $D$ is dense in $\Bbb R$ if every non-empty open interval of $\Bbb R$ contains a point of $D$; in symbols, $D$ is dense in $\Bbb R$ if and only if $D\cap(a,b)\ne\varnothing$ whenever $a,b\in\Bbb R$ and $a<b$. The set $\Bbb Q$ of rationals is dense in $\Bbb R$: if $a$ and $b$ are real numbers, and $a<b$, there is always a rational number between $a$ and $b$, so $\Bbb Q\cap(a,b)\ne\varnothing$. There is also always an irrational number between $a$ and $b$, so $\Bbb R\setminus\Bbb Q$, the set of irrationals, is also dense in $\Bbb R$. And of course $\Bbb R$ itself is dense in $\Bbb R$.
Another example of a dense subset of $\Bbb R$ is $\Bbb R\setminus\Bbb Z$, the set of real numbers that are not integers: you can easily prove that if $a<b$, the interval $(a,b)$ contains a non-integer. Similarly, $\Bbb R\setminus F$ is dense for any finite $F\subseteq\Bbb R$.
Here are a couple of less obvious examples. Let $$D=\left\{\frac{2m+1}{2^n}:n\in\Bbb N\text{ and }m\in\Bbb Z\right\}\;;$$ the elements of $D$ are the dyadic rationals, the rational numbers whose denominators in lowest terms are powers of $2$. This set $D$ is dense in $\Bbb R$; you might try to prove that $D\cap(a,b)\ne\varnothing$ whenever $a<b$. HINT: For a fixed $n$, the dyadic rationals with denominator $2^n$ are $\frac1{2^n}$ apart. Finally, let $C$ be the middle-thirds Cantor set; then $C$ does not contain any non-empty open interval, so $\Bbb R\setminus C$ intersects every non-empty open interval and is therefore dense in $\Bbb R$.