# Prove that there exists a continuous function $f:\mathbb{R}\to\mathbb{R^2}$ such that $f(\mathbb{Z})=\mathbb{Z^2}$

It is required to prove that there exists a continuous function $f:\mathbb{R}\to\mathbb{R^2}$ such that $f(\mathbb{Z})=\mathbb{Z^2}$. The following is my attempt.

Let $f:\mathbb{Z}\to\mathbb{Z^2}$ be a bijection (the existence of such a function is guaranteed by the equinumerosity of $\mathbb{Z}$ and $\mathbb{Z^2}$ ). Then $f:\mathbb{Z}\to\mathbb{R^2}$ is such that $f(\mathbb{Z})=\mathbb{Z^2}$. Moreover $f$ is continuous as the topology on $\mathbb{Z}$ is discrete as a subspace of $\mathbb{R}$, and $\mathbb{Z}$ is closed. Therefore by Tietze's extension theorem $f$ can be extended continuously over $\mathbb{R}$. Now we have the required result.

• This would be a more interesting question if $f$ is required to be bijective. But your solution looks correct. – Batominovski May 22 '17 at 12:32
• @Batominovski There is no continuous bijection between $\mathbb{R}$ and $\mathbb{R}^2$. See this post math.stackexchange.com/questions/47547/… – Darth Geek May 22 '17 at 12:43
Here the curve has constant "speed" $1$.
• @Janitha357: let $f(0)$ land on any grid point, $f(1)$ the grid point 1 away along the curve in some direction, and so on. This is a continuous map $f: \mathbb{R} \to \mathbb{R}^2$. – Joppy May 22 '17 at 14:51