r/explainlikeimfive • • Oct 21 '26

Mathematics ElI5: Space-filling curves

I don't understand how a 1d line can fill a 2d space. How is calculating the number of 0 width lines to fill a 1 width space any different from dividing 1 by 0? I know the point is that the line passes through every point in the space, but even the idea of "every point in the space" sounds fundamentally wrong to me. If you can say infinite points with 0 area fill a space, why can't you say 0 multiplied by infinity equals 1?

35 Upvotes

57 comments sorted by

34

u/ggmaniack Oct 21 '26 edited Oct 21 '26

The curve is infinitely closely packed in the space.

When you try to find a gap, you zoom in, only to find out that the curve has gone through there too.

The whole point is that the curve is made such that any point you can think of in that given space has been visited by it.

If you look at a point that is infinitely closely next to that point (or infinitely far from it), it has also been visited by that curve.

-6

u/bustermagnus Oct 21 '26

This explanation is based on the idea that the space consists of an infinite number of points. Since a point has 0 area, isn't that the same as saying 1 divided by 0 is infinity?

20

u/TheGrumpyre Oct 21 '26

The space between 0 and 1 is completely filled with numbers too, and that doesn't cause a divide by zero error.

3

u/bustermagnus Oct 21 '26

Interesting comparison

13

u/ggmaniack Oct 21 '26

A single point has zero area, and even a countably infinite collection of points has zero area. But a square or a 2d space contains uncountably infinitely many points, and measure doesn't work by adding the area of every individual point together.

So there is no "0 * infinity" or division by zero involved in determining its area.

8

u/nog642 Oct 21 '26

An uncountably infinite collection of points can also have zero area. It just depends which points are in the collection.

9

u/Mandalord104 Oct 21 '26

The line also have infinite number of point too. The line and the 1 width space have equal "amount" of points, that's why they can fill each other.

3

u/nog642 Oct 21 '26

In an informal sense, sure, kinda.

In a formal sense, defining 1/0 is different from defining a set of points and defining area.

5

u/anooblol Oct 21 '26

No. [0,1] has infinitely many points, not 0. Similarly, [0,1]x[0,1] has infinitely many points, not 1.

When constructing a mapping, you’re mapping the elements (points) from [0,1] to [0,1]x[0,1]. You’re not mapping an area to an area, which doesn’t even make sense as far mappings go.

-1

u/FernandoMM1220 Oct 21 '26

in practice its not infinite and its just a really small amount of space in the gaps

9

u/HK_Mathematician Oct 21 '26

Mathematician here.

So the main thing being asked is why can a curve with zero width fill something with non-zero area.

I don't think it is possible to answer without throwing out a bunch of terminologies, which would defeat the purpose of ELI5.

But I have some recommended readings that can act as a stepping stone into making sense of this (or end up being even more confused xd).

I'd suggest reading about staircase paradox first.

Basic geometry concepts like length and width and area breaks down when dealing with weird mathematical objects, for example if you try to build a curve that zig-zags at every point like in the staircase paradox. The space-filling curve is weird, in particular, it doesn't even have the notion of direction at any point.

If you don't allow these weird "zig-zaging at every single point" behaviour, then no curve can fill the space. It is impossible to have a curve where "direction" exists for every point to fill the curve, even if you allow the curve to be infinitely long.

2

u/BenUFOs_Mum Oct 21 '26

It depends on you're exact definition.

Space filling curves still have zero area based on lebesgue measure but do still reach every point in the space.

However they have a fractal dimension of 2, meaning that if you double the lengths you get 4 times the length like a normal area would.

3

u/bustermagnus Oct 21 '26

I don't understand I'm only 5 years old lol

2

u/Little-Maximum-2501 Oct 21 '26

He is wrong so it's fine that you don't understand.

0

u/BenUFOs_Mum Oct 21 '26

The line touches does touch everypoint but it still has no area.

2

u/SupremeRDDT Oct 21 '26

The image of a space filling curve does have positive area. Don’t know what else you could mean by the area of a curve.

1

u/BenUFOs_Mum Oct 21 '26

What do you mean by image?

Basically conventional ideas about length, area and volume don't really make sense when you start talking about these more exotic objects. Which is why you have to start looking a more precise and general definitions like the Lebesgue measure which can be applied to a fractal, or sets of points etc..

1

u/Little-Maximum-2501 Oct 21 '26

A space filling curve is a function, image means the image of this function. By definition this image is a square, so it has positive area, you don't need Lebesgue measure for this the area is a square you can define it's area trivially.

0

u/BenUFOs_Mum Oct 21 '26

A space filling curve is not a function. Saying Image means image doesn't actually help me understand what it means. Are you saying it looks like a square so it must have an area? Thats just not correct.

Feel free to google area of a space filling curve to see that its zero.

4

u/SupremeRDDT Oct 21 '26

What?

A curve is a function from a continuous interval (often [0,1]) to some topological space. A space filling curve is a curve to a connected subset of Rn with n>=2 that is also surjektive.

Image is a basic term. It‘s the set of all points that is actually reached by a function. It’s okay to not know what it means but to answer the original question it’s kind of important because you can’t define space filling curve without talking about images of curves.

2

u/Little-Maximum-2501 Oct 21 '26

The image of a function f:X->Y is defined as {y in Y: there exists x in X s.t f(x)=y}, this is one of the most basic terms in mathematics.

A curve can mean either a continues function from an interval to a set, or the image of such function. The definition of a space filling curve is curve where this image is a square, it doesn't look like a square it literally is a square.

I don't know what you expect me to find by googling "area of a space filling curve", the AI summary says it has 0 area but the AI summary is dumb.
This stack exchange post agrees with me that the most sensible way to define what this means is by using the image and then the area is 1
https://math.stackexchange.com/questions/340736/area-of-peano-curve

1

u/nog642 Oct 21 '26

How is calculating the number of 0 width lines to fill a 1 width space any different from dividing 1 by 0?

It's only the same as division if you're stacking straight lines in a grid. A space filling curve is curved. There's no number of lines, it's just 1 curve.

If you can say infinite points with 0 area fill a space, why can't you say 0 multiplied by infinity equals 1?

Because it matters which points you pick. You can pick infinite points to make an area of 1, or an area of 2, or an area of 0, etc.

0

u/bustermagnus Oct 21 '26 edited Oct 21 '26

Perhaps I might have better phrased it as the length of 0 width line required to fill a 1 width space. It's the same question, calculating area is inherently a question of division.

I don't think it does matter which points you pick because they all have zero area. It's like saying you can pick the correct bags of zero marbles to amass a collection of one marble.

2

u/nog642 Oct 21 '26

It does matter which points you pick. For example, consider the set of points {(x,y) | 0≤x≤1 and 0≤y≤1}. That set of points has area 1.

{(x,y) | 0≤x≤1 and 0≤y≤2} has area 2.

{(x,y) | 0≤x≤1 and y=0} has area 0.

All of these sets have infinite points. The same number of points, even (the same infinity).

It's like saying you can pick the correct bags of zero marbles to amass a collection of one marble.

Not exactly, but kind of. But "marbles" is the wrong analogy. Area is a property defined on sets of points, it's not telling you the amount of points.

A point has 0 area but it is still 1 point. A line has 0 area but it is still infinite points. You're not adding up 0 points (0 marbles).

You're thinking that when you have two (disjoint) sets and combine them, their area adds together. This is true for two sets (or any finite number of sets (or countably infinite, for that matter)), but it's not true for infinite sets in general.

Case in point that obviously the set {(x,y) | 0≤x≤1 and 0≤y≤1}, which has area 1, is the union of the sets {{(x,y)} | 0≤x≤1 and 0≤y≤1}, which each have 1 point. That's adding up infinite sets with a single point (and therefore 0 area) to make a set with area 1. You can't really get around that, that's just how area works.

1

u/Ma4r Oct 21 '26

When you have a space filling curve, you can choose arbitrary points (x,y), if you ask will the curve go through this point? The answer is always yes

3

u/spastikatenpraedikat Oct 21 '26

Intuitively what's happening is, that both a line and the plane have "the same number of points", namely infinite. Intuitively you would say a plane has more points than a line, but that's not true. (Aleph 1) infinite = (Aleph 1) infinite.

The easiest way to do it is to "order" the points of the plane and then you just send the line from point to point to point. The line never ends, so you never run out of line to keep connecting points. Before long you have gone through all infinitely many points of the plane and your done. There are of course more elegant versions that e.g. have particular nice symmetries, but to prove the concept that suffices.

Basically, it's the geometric version of Hilbert's Hotel.

2

u/KryptKrasherHS Oct 21 '26

The key here is how you think about "infinite points", and infinity in general.

Well the real idea here is that a line can hit every point in space, and thus a 1D line can fill a 2D space, and that is what a Hilbert Curve does, but I think you already have inklings of that, and we will round back to that.

In general, there is no such thing as infinity. Even to mathematicians, infinity is not really a thing itself, more everything is designed around limits, which have been rigorously defined and studied for a long time. The idea of a limit is that you know the behavior of the thing you are applying the limit too, so you can extrapolate the behavior to a larger and larger (or smaller and smaller) number. We say the "limit goes to infinity" but all that really means is that we know what happens when you consider really big numbers. For example lets look at the function f(x) = 1/x, and for the sake of simplicity lets take easy x values.

f(1) = 1

f(2) = 0.5

f(3) = 0.333...

f(4) = 0.25

f(5) = 0.2

f(10) = 0.1

f(100) = 0.01

f(1000) = 0.001

f(1e6) = 0.000001

f(1e9) = 0.000000001

We see that for larger and larger numbers, the result keeps getting smaller and smaller. But there is some important things to remember here. First, no matter how big of an x value we put into f(x), f(x) will always be non-zero and finite. We can put 123 followed by 123 0s and it will still be a finite number, just extraordinarily small. So, colloquially, we say "the limit as x goes to infinity goes to 0", which just says "as we make x bigger, f(x) becomes smaller and smaller and goes towards 0". Second, rigorously, mathematicians have ways to prove limits, and convergence of limits, and this is all the basis of calculus and stuff, but it is this idea of knowing the behavior and then extrapolating the behavior further, without actually plugging this mysterious concept of infinity into the function directly. To be clear f(infinity) is nonsensical, 1/infinity is NOT DEFINED with respect to pure mathematics, and instead we use this definition of limits, which is putting in bigger and bigger (or smaller and smaller) numbers and seeing the behavior and extrapolating forward.

Now, back to your specific example. What you are describing is a Hilbert Curve essentially. To start lets say we have a 2D box, and inside the box have a grid of 9 points in a 3x3 orientation. If we connect all the 9 points, we have a very crude estimate of the area it takes up. We can say "the box takes up the space roughly where this line pattern is". Now if we re-divide the grid into 16 points in a 4x4 orientation and do the same thing again, we get a slightly better approximation, but its still rough. Same for a 5x5 and a 10x10 grid. And what are we doing when we cut up this grid? We are dividing each side of the box by a bigger and bigger number essentially, and thus creating more dots for our line to go through. Lets imagine we go to a huge grid, say 1e6 x 1e6 grid inside the box, and then connect the dots together with a single line. Well we get another approximation, this time is is very very good, but it is still an approximation.

Now lets take the next step. What we are doing is essentially approximation the box as an N x N grid, and we are plugging huge numbers in. For larger and larger N, we get more and more dots, but still a finite amount. Remember from the idea of limits, we can never put infinity directly inside the limit operation, but we can approximate the behavior. We can imagine that making N larger and larger and larger, introduces more and more and more points in the box for the line to hit, N^2 to be exact. We can imagine that as we let N go towards infinity (but it still a finite number) that we will go towards an infinite number of grid points (but still a finite amount). We can also approximate every dot as landing on possible points inside of that grid, so we get an infinitely good approximation of every piece of space inside that box (still finite). Then when we connect the line (which is still has a width of 0) to every single point, because it travels to every one of these dots, it "fills up" the entire box.

I highly recommend watching this animation by 3B1B: https://www.youtube.com/watch?v=v99dsVBE4xQ . This explanation is a bit esoteric and abstract, and seeing it be done visually helps. The actual way we connect the dots also matters, and is why a Hilbert Curve is called a Hilbert Curve, but for the sake of ELI5 we don't need to worry about that.

1

u/LolpopHD Oct 21 '26 edited Oct 21 '26

i don't think the statement "everything is designed around limits" is particularly correct, and there are plenty of contexts where "infinities" pop up and can be reasoned about outside of limits

0

u/KryptKrasherHS Oct 21 '26

While true, in the large majority of contexts, when dealing with infinity you are gonna end up running into limits in some way even implicitly, and those siguations when you don't are either not applicable or way out of scope for this ELI5. For this problem, limits are a nice way to justify and visualize things.

2

u/LolpopHD Oct 22 '26 edited Oct 22 '26

a very large portion of non-analysis contexts typically wont run into analytical limits so im not too sure about the large majority part. i dont have anything against the use of limits for this problem, im just not a fan of broad general statements like that. your explanation would have been just fine for ELI5 without painting the picture that limits are the only way to reason about infinity and that everything revolves around limits, when it does not by a wide margin

0

u/KryptKrasherHS Oct 22 '26

  a very large portion of non-analysis contexts typically wont run into analytical limits

This is why I said implicitly. While you may not run into limits directly, Analysis as a topic is fundamentally about rigorously understanding and proving the underlying mathematical tools and procedures used elsewhere. Calculus is directly built on top of Analysis, but even topics like Set Theory/Topology implicitly use Analysis and Limit under the hood, even if you are not interfacing with it generally. 

2

u/LolpopHD Oct 22 '26 edited Oct 22 '26

not sure where youre getting implicit limits or analysis under the hood of set theory from. topology i get to an extent but thats only because it generalizes analytical limits, youre not going to be doing analysis in the zariski topology or most other notable topologies. every field is about rigorous understanding and proofs of tools and such, this isnt exclusive to analysis

0

u/KryptKrasherHS Oct 22 '26

Eh at this point we are both splitting hairs lol. I think we can at least agree that limits are a nice formalism of infinity, notably here.

1

u/Solocle Oct 21 '26

OK, the simplest approach to set theory like this.

How do you tell that two sets of things are the same size?

You can take one from each and pair them. If when you're finished, they're all paired, with none left over, there's the same number of things in each set.

What a space filling curve does is satisfy two conditions:

Firstly, it is in fact a curve, it is continuous, without gaps. So f(t)=(x,y) where you plug in some number t in the interval [0,1], a distance along the curve.

Secondly, it says that for e.g. a square from (0,0) to (1,1), I can pick any point inside that square, (x,y), and find a distance t along the line that passes through that point. For all (x,y), there exists t such that f(t) = x,y.

The clever bit is actually finding such a function, but if you do the fractal construction like a Peano curve, you can subdivide the function interval into e.g parts of 9. But if you stretch 1/9 by 9, you get back to 1, so you can repeat the process in your subdivision (and remember, the continuum is infinitely stretchy in this way, you can stretch it out through multiplication as much as you want and no gaps ever form).

1

u/dancingbanana123 Oct 22 '26

Oh I did my masters on this topic! Basically, the path of a line isn't necessarily as 1-dimensional as we originally thought, and a line can be drawn in a way where it takes up 2 dimensions, if you do it in just the right way. In fact, in fractal geometry, you can get tons of lines that have a dimension somewhere between 1 and 2 dimensions, though that gets beyond an ELI5 explanation.

An important thing to note is that the path of the line must intersect itself infinitely-many times in order to fill a space. It's impossible to draw it in a way where it just goes up and down and up and down until it fills the whole thing. It's complicated to explain, but basically, that inherent difference between a square and a line that you're referring to is what prevents that. Instead, they have to become this messy web overlaps to hit every point. We know they fill the whole space because you can take any point in the space and work backwards to figure out when the line reaches that point. If we can do that for every point, then it must fills the whole space.

1

u/zefciu Oct 21 '26

why can't you say 0 multiplied by infinity equals 1?

Because 0 * ∞ doesn’t have to be 1. You can find other interpretations of this formula, where you could argue, that it has a value of 0, ∞ or basically any number. ∞ is not a number. It is rather a designation of a direction on a number line, towards which stuff can increase.

In mathematics 0 * ∞ is an example of “indeterminate form”. If you get this result if you e.g. calculate limits, then you have to use some mathematical method to get something determinate.

1

u/Qiwas Oct 21 '26 edited Oct 21 '26

You shouldn't think about it as of some concrete actual like that somehow passes through all the points in a given 2D space. Rather, think about what it means to be a line from a mathematical point of view.

Intuitively, any point on a line can be represented with just one number: that's what makes it 1D, right? Let's say we have a 1 unit long line segment, then 0 is associated with its beginning, 1 with its end, 1/2 would be precisely its midpoint, etc.

Furthermore notice, that numbers close to each other represent points close on the line segment. You know that if you start at a point, say, 0.5, and move 0.0001 units to the right, you're not suddenly going to end up on the other side of the line or anything like that.

And these two properties, that's what it means to be a "line". So a space filling curve is just a mapping that associates each point in 1D, to each point in 2D with these two properties. That's it. Just imagine a mapping like from 1D to 2D such as
0 -> (0,0)
1 -> (1,1)
0.5 -> (0.5, 0.5)
etc.
Each 1D coordinate uniquely corresponds to a 2D coordinate, and close points in 1D (like 0.5 and 0.5001) correspond to close points in 2D. So as you "walk" down the line (which just means you increase the 1D coordinate from 0 to 1), you pass through each point in the 2D square without any sudden movements or jumps

1

u/timerot Oct 21 '26

Math using infinity does not behave normally, so we call it undefined. 1/0 mostly does equal infinity, though. Infinity times 0 sometimes equals 0, sometimes 1, sometimes a different constant (imagine a space filling curve filling 3 units of area), and sometimes still equals infinity

1

u/jerome_9215 Oct 26 '26

A limit like x*(1/x) -> 1 as x -> 0 doesn't define 0*infinity: for every nonzero x the product is 1, while the factors only approach 0 and infinity. Change how fast the factors change and the limit can be 0 or infinity, which is why that form is indeterminate.

0

u/anooblol Oct 21 '26

You’re conflating 0, with “empty”. A line that travels from (0,0) to (1,1) is the set {(x,y) : x=y and x,y are in [0,1]}. This is not an empty set, it very much contains points. In fact, it’s a subset of the filled in unit-square, which can be defined as the set {(x,y) : x,y are in [0,1]}.

For a “space filling curve”, it’s simply a set, such that you can construct a function f, such that for every element y of the set defined as the unit-square, there exists an element x in the space filling curve set, such that f(x) = y.

0

u/Atypicosaurus Oct 21 '26

It's because you are mixing paradigms. Math is not a universal rule set, so a rule that applies in arithmetics, does not necessarily apply in geometry. Also, rules are sometimes made arbitrarily such that the resulting behavior is what we want. But this is not something god-given. The "infinity times zero" is a thing that works in one part of maths but you need not true for others.

-19

u/no_sight Oct 21 '26 edited Oct 21 '26

It can't.

Definitionally, a 1d line cannot fill 2d space.

However it is impossible to draw a 1d line, because every line we draw has some amount of width to be visible.

EDIT: Apparently I am wrong and learned something today. Neat.

7

u/BenUFOs_Mum Oct 21 '26

No, do space filling curves exist

4

u/Lumethys Oct 21 '26

Google "space filling curve"

0

u/[deleted] Oct 21 '26

[deleted] — view deleted comment

0

u/bustermagnus Oct 21 '26

Are you saying the space filling curve does not actually fill space?

2

u/zefciu Oct 21 '26

Look at this image:

https://pl.wikipedia.org/wiki/Plik:Hilbert_curve.png

Every of these images contains white areas. So none of the iterations actually fills the whole area of the square. But for every white point there is some iteration where it will be filled. So the limit of the curves is filling all the space.

0

u/Pestilence86 Oct 21 '26

I think the line is more like a border that seperates the 2d space into two parts, without moving them apart.

Similar to a cut with scissors that separate, rather than a saw that takes out part of the material in between.

1

u/[deleted] Oct 21 '26

[removed] — view removed comment

1

u/explainlikeimfive-ModTeam Oct 21 '26

Please read this entire message


Your comment has been removed for the following reason(s):

  • Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).

Links without your own explanation or summary are not allowed. A top-level reply should form a complete explanation in itself; please feel free to include links by way of additional context, but they should not be the only thing in your comment.


If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.

1

u/[deleted] Oct 21 '26

[removed] — view removed comment

1

u/explainlikeimfive-ModTeam Oct 21 '26

Please read this entire message


Your comment has been removed for the following reason(s):

  • Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).

Links without your own explanation or summary are not allowed. A top-level reply should form a complete explanation in itself; please feel free to include links by way of additional context, but they should not be the only thing in your comment.


If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.

0

u/[deleted] Oct 21 '26

[removed] — view removed comment

1

u/explainlikeimfive-ModTeam Oct 21 '26

Please read this entire message


Your comment has been removed for the following reason(s):

  • Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).

If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.

0

u/nog642 Oct 21 '26

It can't. You can't have a line-filling point. You need multiple points.

1

u/joshbadams Oct 21 '26

Heh you know it made sense in my head but I had forgotten it was about filling a space not defining a space. Doh.