Get AI summaries of any video or article — Sign up free
Hilbert's Curve: Is infinite math useful? thumbnail

Hilbert's Curve: Is infinite math useful?

3Blue1Brown·
5 min read

Based on 3Blue1Brown's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

Stable perception across resolution upgrades requires a mapping where nearby positions in 1D correspond to nearby locations in 2D.

Briefing

Hilbert’s curve earns its keep by solving a practical mapping problem: turning a 2D image grid into a 1D sequence of frequencies in a way that stays stable as resolution increases. That stability matters because a naive “snake” ordering forces many pixel-to-frequency associations to jump around when the camera resolution changes—effectively resetting users’ learned intuition. A Hilbert-curve-style ordering, built from increasingly fine “pseudo-Hilbert” patterns, keeps each point on the frequency line moving less and less, so upgrades refine perception rather than break it.

The setup starts with a sound-to-sight thought experiment. Software takes low-resolution images (like 256×256 pixels), assigns each pixel a unique frequency, and plays louder tones for brighter pixels. If the mapping from pixel space (2D) to frequency space (1D) is arbitrary, the result is chaotic. The key design goal is continuity in a human sense: nearby frequencies should correspond to nearby locations in the image, so that small hearing errors don’t scatter the meaning across the grid.

A “snake curve” achieves this by weaving through pixels row by row, but it has a fatal upgrade problem. When the grid doubles to 512×512, the same position along the frequency line can land in a very different place in the image—especially in the left-right direction—so users would have to relearn which tones correspond to which spatial features. The pseudo-Hilbert construction fixes that by recursively subdividing the square. At order one, the curve connects quadrant centers in a specific pattern. At order two, each quadrant contains a smaller order-one curve, with lower-left and lower-right pieces flipped to avoid awkward discontinuous jumps. Higher orders repeat the idea: subdivide, place smaller curves, flip where needed, and connect tip to tail.

For a 256×256 grid, the relevant order is eight; increasing resolution corresponds to increasing the order. The crucial property is that as the order grows, a fixed point along the curve approaches a specific location in the square rather than wandering erratically. In the finite, pixelated setting, pseudo-Hilbert curves approximate this behavior; in the continuous setting, the true Hilbert curve is defined as the limit of these approximations.

That infinite origin traces back to late-19th-century work on space-filling curves. After Peano’s first discovery in 1890, Hilbert produced a simpler curve in 1891. The goal was counterintuitive: construct a line-like object with zero area that nevertheless passes through every point of a 2D region. The modern definition hinges on continuity and on the convergence of the pseudo-Hilbert mappings for each input value between 0 and 1. Once the limit exists, the resulting function can be shown to be continuous and to fill the unit square.

The broader takeaway is philosophical but grounded in math: patterns developed to handle infinite objects often have finite analogs that become directly useful. Stability under refinement in the Hilbert construction mirrors the formal notion of limits, and similar correspondences appear elsewhere—such as how binary representations relate to infinite series of powers of 2. The practical lesson is to look beneath the surface of “infinite” results; the same machinery that proves them can often power finite tools people can actually use.

Cornell Notes

Hilbert’s curve provides a stable way to map a 1D parameter (like a position along a frequency line) onto a 2D space (like an image grid). In a sound-to-sight scenario, a snake-like pixel ordering would force many associations to jump when camera resolution increases, breaking users’ learned intuition. Pseudo-Hilbert curves avoid that by recursively subdividing the square and flipping sub-curves so that points on the curve move less and less as the order increases. The true Hilbert curve is defined as the limit of these pseudo-Hilbert approximations, relying on continuity and convergence for every input in [0,1]. This infinite construction traces back to Peano and Hilbert’s late-1800s quest to build space-filling curves that pass through every point of a region.

Why does mapping pixels to frequencies become tricky when moving from 2D to 1D?

Pixel space is two-dimensional (a grid of coordinates), while frequency space is one-dimensional (a single ordered list of tones). A good mapping should preserve neighborhood relationships: frequencies that are close together should correspond to nearby locations in the image. That way, small perceptual errors don’t scatter meaning across distant parts of the grid.

What goes wrong with a “snake curve” when camera resolution increases?

A snake curve visits pixels row-by-row in a fixed left-right pattern. When the resolution doubles (e.g., from 256×256 to 512×512), the same position along the frequency line no longer corresponds to the same left-right location in the image. The result is that many pixel-to-frequency associations change abruptly, forcing users to relearn how tones map to spatial positions.

How do pseudo-Hilbert curves improve stability across resolution upgrades?

Pseudo-Hilbert curves are built recursively. At each order, the square is subdivided into a grid (2×2, then 4×4, then 8×8, etc.). Each quadrant contains a smaller copy of the previous-order curve, and certain sub-curves (notably lower-left and lower-right) are flipped so the curve can connect tip-to-tail without long jumps. As the order increases, a fixed point along the curve approaches a specific location in the square rather than wandering.

What makes the true Hilbert curve different from pseudo-Hilbert curves?

Pseudo-Hilbert curves are finite approximations that only trace through a pixel-sized subset when viewed at a fixed resolution. The true Hilbert curve is defined as the limit of all pseudo-Hilbert curves as the order goes to infinity. That limit requires formal convergence: for each input value in [0,1], the sequence of 2D outputs must stabilize to a single point. The resulting function must also be continuous and fill the entire unit square.

What late-19th-century problem motivated Hilbert’s space-filling curve work?

Mathematicians sought mappings from a one-dimensional line into two-dimensional space such that the line runs through every point of a region. The goal was especially striking because the curve is “thin” (zero area) yet still hits every point in a continuous 2D set. Peano discovered an early version in 1890, and Hilbert followed in 1891 with a simpler construction.

Review Questions

  1. In the sound-to-sight mapping, what property of the pixel-to-frequency association prevents users from needing to relearn after resolution changes?
  2. Describe how pseudo-Hilbert curves are constructed at order two, including what gets flipped and why.
  3. What three properties must be proved to justify defining the Hilbert curve as a limit of pseudo-Hilbert curves?

Key Points

  1. 1

    Stable perception across resolution upgrades requires a mapping where nearby positions in 1D correspond to nearby locations in 2D.

  2. 2

    A snake-style traversal fails because doubling resolution can relocate the left-right position associated with the same point along the frequency line.

  3. 3

    Pseudo-Hilbert curves use recursive subdivision and targeted flipping of sub-curves to keep connections short and neighborhood relationships intact.

  4. 4

    The true Hilbert curve is defined as the limit of pseudo-Hilbert curves, relying on convergence for every input in [0,1].

  5. 5

    Continuity is essential to treat the mapping as a “curve” rather than an arbitrary association between numbers and coordinates.

  6. 6

    Space-filling curve research grew from the late-1800s effort to map a 1D line through every point of a 2D region despite the curve having zero area.

  7. 7

    Infinite constructions often have finite analogs: the same limit/stability ideas that define infinite objects can guide practical finite designs.

Highlights

Hilbert-curve-style ordering prevents the “relearning problem” that appears when image resolution increases, because points on the curve move less and less as order rises.
Pseudo-Hilbert curves are built by subdividing the square and recursively inserting smaller curves, with flips in lower-left and lower-right to avoid discontinuous jumps.
The true Hilbert curve is not one finite weaving pattern; it is the limit of those patterns, defined via convergence for each input in [0,1].
Late-19th-century mathematicians pursued space-filling curves to make a zero-area line pass through every point of a 2D region.

Topics

  • Hilbert Curve
  • Space-Filling Curves
  • Sound-to-Sight Mapping
  • Pseudo-Hilbert Construction
  • Limits and Continuity