Virtual laboratory/Mathematics/Fractals and chaos/The Peano curve — a line that fills the square

The Peano curve — a line that fills the square

An extension of the topic of dimension and continuity (beyond the curriculum). There exists a continuous (one-dimensional) curve that passes through every point of a square — a “line” fills a surface, overturning our intuition about dimension. It is built as the limit of curves that wind ever more densely while staying continuous. The first such curve was given by Giuseppe Peano in 1890.

The Peano curve — a line that fills the square
Mathematics · Fractals and chaos · Peano curve — a line that fills the square (1890)
Number of iterations kk2
Can a one-dimensional line pass through every point of a two-dimensional square — “fill” it?
iterations k
2
grid
4×4
length L
3.8
spacing d
0.250
🎯 Challenge: count the cells
streak: 0

I will give you k — work out how many cells of the 2^k×2^k grid the curve visits (it passes through each one once).

What just happened?

As you increase the number of iterations, you watch successive terms of a sequence of curves that wind through the square ever more densely. For small kk you see a simple, angular path; the larger kk, the finer the curve folds, until it looks as if it covered the whole area. The key point: at every step it remains one continuous line — running without a break from corner to corner (green start, red end).

A continuous map of the interval onto the square:

f:[0,1] → continuous  [0,1]2,f([0,1])=[0,1]2f:[0,1]\ \xrightarrow{\ \text{continuous}\ }\ [0,1]^2,\qquad f\big([0,1]\big)=[0,1]^2

In the limit (infinitely many iterations) the Peano curve is a continuous surjection of the interval onto the square: every point of the square has its own moment t∈[0,1]t\in[0,1], at which the curve passes through it. A one-dimensional “line” really does fill a two-dimensional area.

The length grows without bound, the spacing tends to zero:

Lk=4k−12k⟶∞,dk=12k⟶0L_k=\frac{4^{k}-1}{2^{k}}\longrightarrow\infty,\qquad d_k=\frac{1}{2^{k}}\longrightarrow 0

With a 2k×2k2^k\times 2^k grid the curve has 4k−14^k-1 segments of length 1/2k1/2^k, so its length doubles every iteration and is divergent. At the same time the spacing between neighbouring “strands” shrinks to 0 — which is why in the limit no point is left unvisited.

Where does this curve come from?

The Italian mathematician Giuseppe Peano constructed it in 1890 — it is the first curve that fills space — a space-filling curve. The discovery shook the contemporary understanding of the notions of dimension and continuity: earlier Cantor had shown that an interval has “just as many” points as a square, and Peano gave this a continuous realization. Here we draw the Hilbert variant — a curve that is easier to render recursively but has the same square-filling property.

Why this matters:

Space-filling curves have real applications today: in computer science (indexing of multidimensional data, image compression, spatial algorithms), computer graphics and measure theory. It is a beautiful example of how precise mathematics can overturn the “obvious” intuition that a line (dimension 1) cannot fill an area (dimension 2). (A topic beyond the standard curriculum — a fascinating curiosity about dimension and continuity.)

Remember: there is a continuous curve that fills the entire square — its length tends to infinity, while the spacing between strands tends to zero. A one-dimensional line passes through every point of a two-dimensional region.

Illustrative model · NexTutor Virtual Laboratory

Enjoyed the experiment? Share it.

It's free — send it to friends from school.

Theory & formulas

Space-filling curve

There exists a continuous map f:[0,1]→[0,1]2f:[0,1]\to[0,1]^2 that is “onto” — it passes through every point of the square. A one-dimensional interval is mapped continuously onto the entire two-dimensional surface.

Construction as a limit

We build a sequence of curves fkf_k that wind ever more densely; the limit f=lim⁡k→∞fkf=\lim_{k\to\infty} f_k stays continuous yet fills the square.

What it overturns

Continuity does not protect dimension — the image of a “line” can have dimension 22. Such a curve is not injective (it must “touch itself”).

Notation: ff the map, [0,1]2[0,1]^2 the unit square, fkf_k the approximations.

Frequently asked questions

›

Can a one-dimensional line fill an entire square?

Yes — the Peano curve is a continuous line that passes through every point of a two-dimensional square.

›

How is the Peano curve constructed?

As the limit of a sequence of curves that wind ever more densely, each of which stays continuous.

›

What are space-filling curves used for?

For indexing multidimensional data, image compression and spatial algorithms in computer science.

Teaching? Embed this experiment on your site.

Free widget — paste it on your school site, blog or notes. It links to the full version.

Teaching a class or tutoring? Guide students in NexTutor →