TITLE: How continuous are functions that map dense sets to dense sets?
QUESTION [5 upvotes]: Let $f:[0,1] \to [0,1]$ be a function with the property that for every dense $D \subset [0,1]$, $f(D)$ is dense in $f([0,1])$. We can note that $f$ need not be continuous. For instance, consider $f(x)=\left|\sin \ \left(\frac{1}{x-1/2}\right)\right|$ with $f(1/2)=0$. 

Is there a nowhere continuous example? If not, how large must the continuity set of such functions be?

REPLY [3 votes]: Here is a nowhere continuous example.
Let $U_1,U_2,U_3,\dots$ enumerate all rational intervals contained in $[0,1]$.
For each $n$ choose two distinct points $u_n,v_n\in U_n$.
Let $I_n=\left(\frac1{n+1},\frac1n\right]$ for $n=1,2,3,\dots$.
Define $f:[0,1]\to[0,1]$ as follows:
$$f(x)=u_n\text{ if }x\in I_n\cap\mathbb Q;$$
$$f(x)=v_n\text{ if }x\in I_n\setminus\mathbb Q;$$
$$f(0)=0.$$
Plainly $f$ is nowhere continuous. If $D$ is a dense subset of $[0,1]$, then for each $n$ we have $D\cap I_n\ne\emptyset$, so $f(D)\cap U_n\ne\emptyset$.