TITLE: Does there exist a function $f:[0,1] \to[0,1]$ such its graph is dense in $[0,1]\times[0,1]$?
QUESTION [6 upvotes]: Does there exist a function $f:[0,1]\to [0,1]$ such that the graph of $f$ is dense in $[0,1]\times[0,1]$?
Not necessarily continuous.

REPLY [2 votes]: For a probabilistic example, let $\{U_n\}$ be an independent and identically distributed sequence of random variables with the uniform distribution on $[0,1]$.  Enumerate the rationals as $\{q_n\}$, and set $f(q_n) = U_n$ and $f(x) = 0$ for irrational $x$.  I claim $f$ has dense graph with probability 1.
Consider an open square $(a,b) \times (c,d) \subset [0,1]^2$, with $a,b,c,d$ rational (and half-open intervals at the boundary, like $(a,1]$, etc, also allowed).  Choose infinitely many rationals $\{q_{n_k}\}$ lying in $(a,b)$.  For each $k$, the probability that $U_{n_k} \in (c,d)$ is $d-c > 0$.  By independence, the probability that at least one of $U_{n_1}, \dots, U_{n_m}$ is in $(c,d)$ is $1-(1-(d-c))^m$.  As $m \to \infty$, this tends to 1, and so with probability 1, there exists some $k$ with $f(q_{n_k}) = U_{n_k} \in (c,d)$, i.e. the graph of $f$ contains a point of $(a,b) \times (c,d)$.
Since there are countably many rational squares, the event that the graph of $f$ contains a point in every rational square is a countable intersection of events of probability 1, hence itself has probability 1.  But every open set in $[0,1]^2$ contains a rational square, so on this event, the graph of $f$ is dense.