From: 3blue1brown

In the realm of mathematics, concepts often deal with infinite quantities, and the essence of a result may only fully make sense in an infinite context [00:00:11]. However, these results can still be incredibly useful in a finite context [00:00:20]. The study of Hilbert curves provides a concrete example of this interplay, particularly in how they relate to the concept of mathematical functions and their continuity [00:00:33].

Functions in Image-to-Sound Translation

Consider software designed to enable “seeing with ears,” where camera data is translated into sound [00:00:44]. For initial experiments, images might be processed at a low resolution, such as 256x256 pixels [00:01:08]. The challenge is to associate each pixel in a two-dimensional “pixel space” with a unique frequency value in a one-dimensional “frequency space” [00:02:06]. This requires defining a function that maps from the two-dimensional pixel space to the one-dimensional frequency space [00:02:06].

A desirable property for such a function is that frequencies close together should correspond to pixels close together in the pixel space [00:02:36]. This can be achieved by weaving a line through each pixel, fixing each pixel to a spot on that line, and then interpreting the unravelled straight line as the frequency space [00:02:57]. This method associates pixels with frequencies [00:03:14].

Pseudo-Hilbert Curves as Functions

The concept of Hilbert curves provides an effective way to define such a mapping. These are not a single curve but rather an infinite family of curves [00:03:41].

The construction of these “pseudo-Hilbert curves” proceeds iteratively:

  • Order-one: Divide a square into a 2x2 grid and connect the centers of the quadrants in a specific “U” shape [00:03:58].
  • Order-two: Subdivide the square into a 4x4 grid. Place a miniature order-one pseudo-Hilbert curve inside each of the original 2x2 quadrants, orienting them appropriately (flipping the lower left and lower right) to ensure a smooth connection between quadrants [00:04:23].
  • Higher Orders: The pattern continues, with an order-N curve embedding order-(N-1) curves in each quadrant, with appropriate flips and connections [00:04:54].

For a 256x256 pixel array, an order-eight pseudo-Hilbert curve would be used [00:05:22]. Defining such a curve that weaves through each pixel is equivalent to defining a function from pixel space to frequency space, as each pixel is associated with a point on the line [00:05:31].

A key advantage of the Hilbert curve technique over a simpler “snake curve” (which goes row by row) is its stability when increasing resolution [00:06:06]. With a snake curve, upgrading from 256x256 to 512x512 pixels causes many points on the frequency line to map to entirely different parts of pixel space, requiring users to re-learn their intuitions [00:06:16]. In contrast, with the Hilbert curve, as the order of the pseudo-Hilbert curve increases, a given point on the line moves less and less, approaching a more specific point in space [00:06:54]. This allows users to fine-tune rather than re-learn [00:07:09].

Defining Continuity for Mathematical Functions

To formally define the Hilbert curve and understand its properties, it’s necessary to formalize what these curves are as functions [00:09:47]. These are functions that take a single number (e.g., between 0 and 1, representing a point on a line) as input and output a pair of numbers (coordinates in 2D space) [00:09:51].

The crucial property that distinguishes a curve from any arbitrary association between numbers is continuity [00:10:33].

Continuity

The intuition behind continuity is that the output of a function should not suddenly jump when its input changes smoothly [00:10:43].

More rigorously, a function is continuous at an input point ‘a’ if, for any desired smallness of a circle drawn around the output ‘b’ (which is the function’s output for input ‘a’), you can always find a sufficiently small circle around ‘a’ such that all input points within that ‘a’-circle map to points within the ‘b’-circle [00:11:08].

If there’s a lower bound on how small the output circle can be made, no matter how small the input circle, then the function is discontinuous at that point [00:12:07]. A function is continuous as a whole if it is continuous at every possible input point [00:12:27].

The Hilbert Curve as a Limit of Functions

An actual, bonafide Hilbert curve is not any one of the pseudo-Hilbert curves, but rather the limit of all of them [00:09:36]. This rigorous definition relies on a key property: for a given input point (e.g., 0.3), applying each successive pseudo-Hilbert curve function to this point results in corresponding outputs that approach a particular point in space as the order of the curve increases [00:12:47]. This sequence of outputs always stabilizes and approaches a specific point in 2D space, regardless of the starting input [00:13:02]. This is unlike snake curves, where outputs associated with a given input become wildly erratic with increasing resolution [00:13:15].

The Hilbert curve function is then defined as follows: for a given input value, the output is the limit of the sequence of points in 2D space obtained by applying each successive pseudo-Hilbert curve function at that input [00:13:41]. Since the sequence of pseudo-Hilbert curve outputs always converges, this function is well-defined [00:14:00].

For this to be a true “space-filling curve,” three things must be proved [00:14:17]:

  1. The outputs of the pseudo-Hilbert curve functions converge, ensuring the Hilbert curve function is well-defined [00:14:19].
  2. The resulting function is continuous, meaning it qualifies as a “curve” [00:14:29].
  3. Every single point in the unit square is an output of this function, confirming it fills space [00:14:35].

These three facts are indeed true [00:14:48]. The Hilbert curve can even be extended to fill all of continuous space by tiling space with squares and chaining Hilbert curves together in a spiraling pattern [00:14:53]. This demonstrates that a one-dimensional line can hit every single point in an infinitely extending, richly dense two-dimensional space [00:15:27].

Connection Between Finite and Infinite

The core property that makes pseudo-Hilbert curves useful both in the finite sound-to-sight application and in their infinite origins is that points on the curve move less and less as the order of the curves increases [00:15:43]. In the finite context, this meant stable intuitions upon resolution upgrades [00:15:58]. For mathematicians, this property ensured that the limit of a sequence of curves was a meaningful concept [00:16:07].

This connection between the infinite and finite worlds is common in mathematics [00:16:19]. Often, the same patterns and constructs used to define and prove infinite facts have finite analogs that are directly useful [00:16:39]. Theorems about an infinite object are frequently equivalent to theorems about a family of finite objects [00:16:58]. For example, formalizing curve stability for increasing camera resolution would lead directly to the definition of a limit for a sequence of curves [00:17:06]. An infinite object or fractal can be seen as a clean way to encapsulate a truth about a family of finite objects [00:17:23].