Tag: Dimension

  • Can a Curve Fill a Square? The Mathematics of Space-Filling Curves

    Can a Curve Fill a Square?

    A curve is one-dimensional. A square is two-dimensional. So it seems impossible that a single continuous curve could pass through every point of a square.

    Surprisingly, it can.

    There exists a continuous function

    H : [0,1] → [0,1] × [0,1]

    whose image is the entire unit square. In other words, as the parameter moves continuously from 0 to 1, the point H(t) eventually reaches every point of the square.

    Such a curve is called a space-filling curve.

    The Hilbert Curve

    One of the most beautiful examples is the Hilbert curve. Instead of trying to draw the final curve immediately, we construct a sequence of increasingly complicated polygonal curves.

    Start with a square. Divide it into four equal smaller squares and connect their centers in an order that forms a U-shaped path.

    This is the first approximation.

    For the second approximation, divide each of the four squares into four smaller squares. We now have

    42 = 16

    small squares. Inside each group of four, place a suitably rotated or reflected copy of the previous pattern and connect the pieces.

    Repeat the process again and again.

    At stage n, the square has been divided into

    4n

    small squares, each having side length

    2 −n .

    The Squares Become Tiny

    The important feature of the construction is not merely that the number of squares increases. Their size simultaneously decreases to zero.

    A small square at stage n has side length

    12n,

    so its diameter is

    2 2n .

    Therefore,

    2 2n → 0 as n → ∞.

    The construction is examining the square on smaller and smaller scales.

    Why Does the Limit Fill the Square?

    Take any point P in the unit square.

    At the first stage, P belongs to at least one of the four small squares. Call one such square Q1.

    At the second stage, choose one of the smaller squares containing P and call it Q2. Continue in this way.

    We obtain nested squares

    Q1 ⊇ Q2 ⊇ Q3 ⊇ ⋯

    containing P, while

    diam ( Qn ) → 0.

    Since the squares shrink to a point, their intersection is precisely

    ⋂ n=1 ∞ Qn = {P}.

    The Hilbert construction assigns corresponding nested parameter intervals

    I1 ⊇ I2 ⊇ I3 ⊇ ⋯

    whose lengths also tend to zero. Their intersection therefore determines a parameter value t. For this value,

    H (t) = P.

    But P was an arbitrary point of the square. Thus the limiting curve reaches every point of the square.

    A Curve Whose Image Has Area 1

    This produces a remarkable conclusion.

    The domain of the Hilbert curve is the interval [0,1], but its image is

    H ( [0,1] ) = [0,1] × [0,1].

    Consequently, the image of this continuous curve has area

    1.

    This is very different from an ordinary smooth curve, whose area in the plane is zero.

    What Happens to the Length?

    The polygonal approximations also reveal something interesting.

    At stage n, the curve visits 4n small squares. The characteristic distance between neighboring points is of order

    2 −n .

    Therefore the total length is of order

    4n · 2 −n = 2n.

    As n→∞, this quantity tends to infinity.

    2n → ∞.

    Thus the approximations stay inside a square of area 1, but their lengths grow without bound.

    Does This Mean an Interval and a Square Are the Same?

    No.

    The Hilbert curve is continuous and onto, but it is not one-to-one. Different parameter values can correspond to the same point of the square.

    This distinction is essential. There is no continuous one-to-one correspondence with a continuous inverse between an interval and a square.

    The space-filling curve does something subtler: it continuously folds an interval over itself infinitely many times until its image covers the entire square.

    A Dimensional Clue

    There is another way to see why the numbers in the construction fit together so naturally.

    When lengths are reduced by a factor of 2, the number of pieces increases by a factor of 4:

    4 = 22.

    If we informally ask for a dimension d satisfying

    4 = 2d,

    then

    d = log4 log2 = 2.

    This scaling behavior gives a hint of how a construction beginning with a one-dimensional parameter can produce an image that occupies a two-dimensional region.

    Why Space-Filling Curves Are Useful

    Space-filling curves are not only mathematical curiosities. Hilbert-type orderings are useful whenever multidimensional data must be arranged in a one-dimensional sequence.

    The Hilbert ordering has an important locality property: points that are close along the curve tend to remain relatively close in space. This idea appears in spatial indexing, image processing, databases, and algorithms for organizing multidimensional data.

    A construction that originally seemed almost paradoxical therefore connects pure mathematics with practical computation.

    The Main Idea

    The Hilbert curve demonstrates how misleading our finite-dimensional intuition can be when a limiting process is repeated infinitely many times.

    Every finite approximation is just an ordinary polygonal curve. None of these approximations fills the square.

    But the subdivisions become arbitrarily small, and in the limit every point of the square is reached.

    A continuous image of a one-dimensional interval can therefore fill an entire two-dimensional square.


    Continue exploring: Another surprising example of how strange continuous functions can be: Can a Function Be Continuous Everywhere but Differentiable Nowhere?

    Not all interesting curves are as unusual as space-filling curves. Some are designed to create smooth, controllable shapes using only a few points. Discover how this works in Bézier Curves: How Four Points Create Beautiful Shapes .