# Why does the Hilbert curve fill the whole square?

I have never seen a formal definition of the Hilbert curve, much less a careful analysis of why it fills the whole square. The Wikipedia and Mathworld articles are typically handwavy. I suppose the idea is something like this: one defines a sequence of functions $f_i(t) : [0,1]\to {\Bbb R}^2$, and then considers the pointwise limit $f(t) = \lim_{i\to\infty} f_i(t)$.

But looking at the diagram, it is not clear that the sequence converges. I can imagine that we might think of following a single point in the range of $f_i$ as $i$ increases, and that point might move around, but only by $2^{-i}$ at each stage as we pass from $f_i$ to $f_{i+1}$, and so eventually approaches a limiting position. But I don’t know how we’d get from there to showing that $f_i(t)$ converges for a particular value of the argument, especially for an argument other than a dyadic rational.

And even if it does converge, every point in the range of each $f_i$ has at least one rational coordinate, so it is not at all clear why a point like $({1\over\sqrt2}, {1\over\sqrt2})$ should be in the range of $f$.

If there is an easy explanation, I would be glad to hear it, but I would also be glad to get a reference in English.

Looking at the pictures, the partial curves are obtained by joining the centres of smaller squares within the square. In the first step one divides the unit square into 4 squares of side $1/2$. Then each of these squares is divided again into $4$ squares, and so on. So the whole thing is reduced to the numbering of the successive subdivisions of the square: $f_n$ will be the curve obtained by joining the centres of the $4^n$ squares of side $2^{-n}$ according to the proper numbering scheme.

One can make the convention that $f_n:[0,1]\to[0,1]^2$, and we represent the part of the line corresponding to the $k^{\rm th}$ square using the interval $[(k-1)4^{-n},k\,4^{-n})$.

The numbering for the first $4$ squares (with sides $1/2$) is $1,2,3,4$ where $1$ is the lower left and then we proceed clockwise.

Given then $n^{\rm th}$ ordering, we obtain the $(n+1)^{\rm th}$ ordering in the following way: the $4^{n+1}$ squares are grouped in four main groups of $4^{n}$ squares corresponding to the four “quadrants” of the unit square (“first” quadrant is lower left, “second” quadrant is upper left, “third” quadrant is upper right, “fourth” quadrant is lower right). In each quadrant we will use the numbering from the $n^{\rm th}$ numbering, in the following way:

First quadrant: we take the $n^{\rm th}$ numbering, rotate it $90$ degrees clockwise and use reverse order.

Second quadrant: we take the $n^{\rm th}$ numbering in its original order (of course, replacing $1$ with $4^n+1$, $2$ with $4^n+2$, etc.

Third quadrant: we take the $n^{\rm th}$ numbering in its original order (of course, replacing $1$ with $2\times4^n+1$, $2$ with $2\times4^n+2$, etc.

Fourth quadrant: we take the $n^{\rm th}$ numbering, rotate it $90$ degrees counter-clockwise and use reverse order, starting with $3\times4^n+1$.

(this is not that easy to write or read, but it is very easy to check if you draw the squares)

The two claims to be proven are:

1) the sequence $\{f_n\}$ converges uniformly;

2) the limit function touches every point in the square.

To prove 1), we note that in the interval $[k4^{-n},(k+1)4^{-n})$, both $f_n$ and $f_{n+1}$ take values in the same square of side $2^{-n}$. This shows that

Regarding 2), if we write $f=\lim f_n$, then $f$ is continuous, and so the image of the compact interval $[0,1]$ is compact, so in particular it is closed. Fix any point $(x,y)\in[0,1]^2$. Fix $n$; then there exists a square from our grid, of side $2^{-n}$ that contains $(x,y)$; say it’s the $k^{\rm th}$ one. Then

Since $f=f_n+\sum_{m=n}^\infty (f_{m+1}-f_m)$,

This shows that $(x,y)$ is in the closure of the graph of $f$, but we already know that the graph of $f$ is closed, and so the image of $f$ is $[0,1]^2$.