Hilbert Curve — Definition, Formula & Examples
A Hilbert curve is a continuous, space-filling curve that passes through every point of a unit square. It is constructed as the limit of an iterative process that repeatedly subdivides the square into smaller quadrants and connects their centers in a specific pattern.
The Hilbert curve is the limit of a sequence of piecewise-linear approximations , where each is a continuous bijection from onto a path visiting all sub-squares of a grid. The limiting map is a continuous surjection from the unit interval onto the unit square, demonstrating that a one-dimensional path can fill a two-dimensional region.
How It Works
Construction begins with the order-1 Hilbert curve , a U-shaped path connecting the centers of four quadrants of the unit square. To build from , you divide each quadrant into four sub-quadrants, place a copy of inside each one (applying rotations and reflections as needed), and connect adjacent copies with short linking segments. At each iteration, the curve visits grid cells and has total length proportional to . The limiting curve is continuous and surjective but nowhere differentiable, with Hausdorff dimension 2.
Worked Example
Problem: Determine how many grid cells the order-3 Hilbert curve visits, and compute the number of straight-line segments in its piecewise-linear approximation.
Step 1: At order , the Hilbert curve visits grid cells arranged on a grid. For :
Step 2: The piecewise-linear path connects the centers of all 64 cells in sequence, so the number of line segments is one fewer than the number of cells:
Step 3: Each segment has length , so the total path length is:
Answer: The order-3 Hilbert curve visits 64 grid cells, consists of 63 line segments, and has a total path length of .
Why It Matters
Hilbert curves preserve spatial locality better than simple row-major orderings, making them valuable in database indexing, image processing, and geographic information systems. In computational geometry and parallel computing, Hilbert curve mappings are used to partition multi-dimensional data so that nearby points in space remain close along the 1D curve, reducing cache misses and improving query performance.
Common Mistakes
Mistake: Assuming the Hilbert curve is a bijection from to .
Correction: The limiting curve is surjective (onto) but not injective — some points in the square are visited by more than one parameter value. A continuous bijection from to cannot exist because removing a point from disconnects it, but removing a point from does not.
