6

Is there a function almost everywhere $0$ on $\mathbb{R}$ whose graph is dense in $\mathbb{R^2}$?

How to establish such strange funciton?

Greg Martin
  • 78,820
Shine
  • 3,025
  • 13
  • 26

3 Answers3

5

Yes. Define a function $f:\mathbb{Q} \rightarrow \mathbb{Q}$ such that for every $q \in \mathbb{Q}$ and every interval $I$ there is $p\in I$ such that $f(p)=q$. This is actually easy to achieve, enumerate pairs $(I,q)$ here $I$ is an interval with rational endpoints (there are countably many) amd $q$ is rational. Now at stage $n$ chose $p \in I_n$, that has not already been defined, there are infinitely many, and define $f(p)=q_n$.

Now define $f(x)=0$ if $x$ is irrational.

To show density let $(x,y)\in \mathbb{R}^2$ and $\epsilon >0$ chose $I\subseteq (x-\epsilon, x+\epsilon)$ to have rational endpoints and $q \in (y-\epsilon, y+\epsilon)$ rational then there is $p \in I$ such that $f(p)=q$

then

$$|(p,f(p))-(x,y)| \leq \sqrt{2}\epsilon$$

4

Hint: define $f$ separately on the rationals and the irrationals.

Robert Israel
  • 448,999
3

Enumerate the countably many open rational (i.e. having rational center and radius) disks $\subseteq \mathbb R^2$ as $B_i,i\in\mathbb N$ (or take any other countable basis of the topology). Recursively pick a sequence $(x_n,y_n)\in\mathbb R^2, n\in\mathbb N$ with the following constraints: $(x_n,y_n)\in B_n$ and $x_n\notin\{x_1,\ldots,x_{n-1}\}$. (This is possible because the first constraint allows infinitely many $x$ and the second constraint disallows only finitely many). Now define $$f(x)=\begin{cases}y_n&\text{if $x=x_n$ for some $n\in\mathbb N$}\\0&\text{otherwise}\end{cases}$$ Then $f$ is zero except on a countable set and its graph intersects every nonempty open set, hence is dense in $\mathbb R^2$.