### Video Transcript

Who doesn’t like fractals? They’re a beautiful blend of simplicity and complexity, often including these
infinitely repeating patterns. Programmers, in particular, tend to be especially fond of them. Because it takes a shockingly small amount of code to produce images that are way
more intricate than any human hand ever could hope to draw. But a lot of people don’t actually know the definition of a fractal, at least not the
one that Benoit Mandelbrot, the father of fractal geometry, had in mind.

A common misconception is that fractals are shapes that are perfectly
self-similar. For example, this snowflake looking shape right here, called the Von Koch snowflake,
consists of three different segments. And each one of these is perfectly self-similar, in that when you zoom in on it, you
get a perfectly identical copy of the original. Likewise, the famous Sierpinski triangle consists of three smaller identical copies
of itself. And don’t get me wrong, self-similar shapes are definitely beautiful. And they’re a good toy model for what fractals really are.

But Mandelbrot had a much broader conception in mind, one motivated not by beauty but
more by a pragmatic desire to model nature in a way that actually captures
roughness. In some ways, fractal geometry is a rebellion against calculus, whose central
assumption is that things tend to look smooth if you zoom in far enough. But Mandelbrot saw this as overly idealized, or at least needlessly idealized,
resulting in models that neglect the finer details of the thing that they’re
actually modeling, which can matter! What he observed is that self-similar shapes give a basis for modeling the regularity
in some forms of roughness. But the popular perception that fractals only include perfectly self-similar shapes
is another overidealization. One that ironically goes against the pragmatic spirit of fractal geometry’s
origins.

The real definition of fractals has to do with this idea of fractal dimension, the
main topic of this video. You see, there is a sense, a certain way to define the word dimension in which the
Sierpinski triangle is approximately 1.585-dimensional. That the Von Koch curve is approximately 1.262-dimensional. The coastline of Britain turns out to be around 1.21-dimensional. And in general, it’s possible to have shapes whose dimension is any positive real
number, not just whole numbers.

I think when I first heard someone reference fractional dimension like this, I-I just
thought it was nonsense, right? I mean, mathematicians are clearly just making stuff up. Dimension is something that usually only makes sense for natural numbers, right? A line is one-dimensional. A plane, that’s two-dimensional. The space that we live in, that’s three-dimensional, and so on. And in fact, any linear algebra student who just learned the formal definition of
dimension, in that context, would agree. It only makes sense for counting numbers. And, of course, the idea of fractal dimension is just made up. I mean, this is math, everything is made up. But the question is whether or not it turns out to be a useful construct for modeling
the world. And I think you’ll agree. Once you learn how fractal dimension is defined, it’s something that you start seeing
almost everywhere that you look.

It actually helps to start the discussion here by only looking at perfectly
self-similar shapes. In fact, I’m gonna start with four shapes, the first three of which aren’t even
fractals. A line, a square, a cube, and a Sierpinski triangle. All of these shapes are self-similar. A line can be broken up into two smaller lines, each of which is a perfect copy of
the original, just scaled down by a half. A square can be broken down into four smaller squares, each of which is a perfect
copy of the original just scaled down by a half. Likewise, a cube can be broken down into eight smaller cubes. Again, each one is a scaled-down version by one-half. And the core characteristic of the Sierpinski triangle is that it’s made of three
smaller copies of itself. And the length of the side of one of those smaller copies is one-half the side length
of the original triangle.

Now it’s fun to compare how we measure these things. We’d say that the smaller line is one-half the length of the original line. The smaller square is one-quarter the area of the original square. The small cube is one-eighth the volume of the original cube. And that smaller Sierpinski triangle, well, we’ll talk about how to measure that in
just a moment. What I want is a word that generalizes the idea of length, area, and volume, but that
I can apply to all of those shapes and more. And typically in math, the word that you’d use for this is measure. But I think it might be more intuitive to talk about mass. As in, imagine that each of these shapes is made out of metal, a thin wire, a flat
sheet, a solid cube, and some kind of Sierpinski mesh.

Fractal dimension has everything to do with understanding how the mass of these
shapes changes as you scale them. The benefit of starting the discussion with self-similar shapes is that it gives us a
nice clear-cut way to compare masses. When you scale down that line by one-half, the mass is also scaled down by one-half,
which you can viscerally see because it takes two copies of that smaller one to form
the whole. When you scale down a square by one-half, its mass is scaled down by one-fourth,
where again you can see this by piecing together four of the smaller copies to get
the original. Likewise, when you scale down that cube by one-half, the mass is scaled down by
one-eighth, or one-half cubed, because it takes eight copies of that smaller cube to
rebuild the original.

And when you scale down this Sierpinski triangle by a factor of a half, wouldn’t you
agree that it makes sense to say that its mass goes down by a factor of
one-third? I mean, it takes exactly three of those smaller ones to form the original. But notice that for the line, the square, and the cube, the factor by which the mass
changed is this nice clean integer power of one-half. In fact, that exponent is the dimension of each shape. And what’s more, you could say that what it means for a shape to be, for example,
two-dimensional, what puts the two in two-dimensional is that when you scale it by
some factor, its mass is scaled by that factor raised to the second power. And maybe what it means for a shape to be three-dimensional is that when you scale it
by some factor, the mass is scaled by the third power of that factor.

So if this is our conception of dimension, what should the dimensionality of a
Sierpinski triangle be? You’d wanna say that when you scale it down by a factor of one-half, its mass goes
down by one-half to the power of — well, whatever its dimension is. And because it’s self-similar, we know that we want its mass to go down by a factor
of one-third. So what’s the number 𝐷 such that raising one-half to the power of 𝐷 gives you
one-third? Well, that’s the same as asking two to the what equals three. The quintessential type of question that logarithms are meant to answer. And when you go and plug-in log base two of three to a calculator, what you’ll find
is that it’s about 1.585.

So in this way, the Sierpinski triangle is not one-dimensional, even though you could
define a curve that passes through all its points. And nor is it two-dimensional, even though it lives in the plane. Instead, it’s 1.585-dimensional. And if you wanna describe its mass, neither length nor area seem like the fitting
notions. If you tried, its length would turn out to be infinite. And its area would turn out to be zero. Instead, what you want is whatever the 1.585-dimensional analog of length is.

Here, let’s look at another self-similar fractal, the Von Koch curve. This one is composed of four smaller identical copies of itself, each of which is a
copy of the original scaled down by one-third. So the scaling factor is one-third. And the mass has gone down by a factor of one-fourth. So that means the dimension should be some number 𝐷 so that when we raise one-third
to the power of 𝐷, it gives us one-fourth. Well, that’s the same as saying three to the what equals four. So you can go and plug into a calculator log base three of four. And that comes out to be around 1.262. So in a sense, the Von Koch curve is a 1.262-dimensional shape.

Here’s another fun one. This is kind of the right-angled version of the Koch curve. It’s built up of eight scaled-down copies of itself, where the scaling factor here is
one-fourth. So if you wanna know its dimension, it should be some number 𝐷 such that one-fourth
to the power of 𝐷 equals one-eighth. The factor by which the mass just decreased. And in this case, the value we want is log base four of eight. And that’s exactly three-halves. So evidently, this fractal is precisely 1.5-dimensional. Does that kind of makes sense? It’s weird, but it’s all just about scaling and comparing masses while you scale.

And what I’ve described so far, everything up to this point is what you might call
self-similarity dimension. It does a good job making the idea of fractional dimension seem at least somewhat
reasonable, but there’s a problem. It’s not really a general notion. I mean, when we were reasoning about how a mass’s shape should change, it relied on
the self-similarity of the shapes. That you could build them up from smaller copies of themselves. But that seems unnecessarily restrictive. After all, most two-dimensional shapes are not at all self-similar.

Consider the disk, the interior of a circle. We know that’s two-dimensional. And you could say that this is because when you scale it up by a factor of two, its
mass proportional to the area gets scaled by the square of that factor, in this case
four. But it’s not like there’s some way to piece together four copies of that smaller
circle to rebuild the original. So how do we know that that bigger disk is exactly four times the mass of the
original? Answering that requires a way to make this idea of mass a little more mathematically
rigorous, since we’re not dealing with physical objects made of matter, are we? We’re dealing with purely geometric ones living in an abstract space. And there’s a couple ways to think about this, but here is a common one.

Cover the plane with the grid and highlight all of the grid squares that are touching
the disk. And now count how many there are. In the back of our minds, we already know that a disk is two-dimensional. And the number of grid squares that it touches should be proportional to its
area. A clever way to verify this empirically is to scale up that disk by some factor, like
two, and count how many grid squares touch this new scaled-up version. What you should find is that that number has increased approximately in proportion to
the square of our scaling factor, which in this case means about four times as many
boxes.

Well, admittedly, what’s on the screen here might not look that convincing. But it’s just because the grid is really coarse. If instead you took a much finer grid, one that more tightly captures the intent
we’re going for here by measuring the size of the circle. That relationship of quadrupling the number of boxes touched when you scale the disk
by a factor of two should shine through more clearly. I’ll admit though that when I was animating this, I was surprised by just how slowly
this value converges to four. Here’s one way to think about this. If you were to plot the scaling factor compared to the number of boxes that the
scaled disk touches, your data should very closely fit a perfect parabola. Since the number of boxes touched is roughly proportional to the square of the
scaling factor. For larger and larger scaling values, which is actually equivalent to just looking at
a finer grid, that data is gonna more perfectly fit that parabola.

Now getting back to fractals, let’s play this game with the Sierpinski triangle,
counting how many boxes are touching points in that shape. How would you imagine that number compares to scaling up the triangle by a factor of
two and counting the new number of boxes touched? Well, the proportion of boxes touched by the big one to the number of boxes touched
by the small one should be about three. After all, that bigger version is just built up of three copies of the smaller
version. You could also think about this as two raised to the dimension of the fractal, which
we just saw is about 1.585. And so, if you were to go and plot the scaling factor in this case against the number
of boxes touched by the Sierpinski triangle. The data would closely fit a curve with the shape of 𝑦 equals 𝑥 to the power 1.585,
just multiplied by some proportionality constant.

But importantly, the whole reason that I’m talking about this is that we can play the
same game with non-self-similar shapes that still have some kind of roughness. And the classic example here is the coastline of Britain. If you plot that coastline into the plane and count how many boxes are touching
it. And then scale it by some amount and count how many boxes are touching that new
scaled version. What you’d find is that the number of boxes touching the coastline increases
approximately in proportion to the scaling factor raised to the power of 1.21. Here, it’s kind of fun to think about how you would actually compute that number
empirically. As in, imagine I give you some shape, and you’re a savvy programmer. How would you find this number?

So what I’m saying here is that if you scale this shape by some factor, which I’ll
call 𝑠. The number of boxes touching that shape should equal some constant multiplied by that
scaling factor raised to whatever the dimension is, the value that we’re looking
for. Now if you have some data plot that closely fits a curve that looks like the input
raised to some power, it can be hard to see exactly what that power should be. So a common trick is to take the logarithm of both sides. That way, the dimension is gonna drop down from the exponent. And we’ll have a nice clean linear relationship. What this suggests is that if you were to plot the log of the scaling factor against
the log of the number of boxes touching the coastline, the relationship should look
like a line. And that line should have a slope equal to the dimension.

So what that means is that if you tried out a whole bunch of scaling factors, counted
the number of boxes touching the coast in each instant, and then plotted the points
on the log-log plot. You could then do some kind of linear regression to find the best fit line to your
data set. And when you look at the slope of that line, that tells you the empirical measurement
for the dimension of what you’re examining. I just think that makes this idea of fractal dimension so much more real and visceral
compared to abstract artificially perfect shapes. And once you’re comfortable thinking about dimension like this, you, my friend, have
become ready to hear the definition of a fractal.

Essentially, fractals are shapes whose dimension is not an integer, but instead some
fractional amount. What’s cool about that is that it’s a quantitative way to say that they’re shapes
that are rough, and that they stay rough even as you zoom in. Technically, there’s a slightly more accurate definition, and I’ve included it in the
video description. But this idea here of a noninteger dimension almost entirely captures the idea of
roughness that we’re going for. There is one nuance, though, that I haven’t brought up yet, but it’s worth pointing
out. Which is that this dimension, at least as I’ve described it so far using the box
counting method, can sometimes change based on how far zoomed in you are.

For example, here’s a shape sitting in three dimensions which, at a distance, looks
like a line. In 3D, by the way, when you do a box counting, you have a 3D grid full of little
cubes instead of little squares. But it works the same way. At this scale where the shape’s thickness is smaller than the size of the boxes, it
looks one-dimensional. Meaning, the number of boxes it touches is proportional to its length. But when you scale it up, it starts behaving a lot more like a tube, touching the
boxes on the surface of that tube. And so, it’ll look two-dimensional, with the number of boxes touched being
proportional to the square of the scaling factor. But it’s not really a tube. It’s made of these rapidly winding little curves. So once you scale it up even more, to the point where the boxes can pick up on the
details of those curves, it looks one-dimensional again. With the number of boxes touched scaling directly in proportion to the scaling
constant.

So actually, assigning a number to a shape for its dimension can be tricky. And it leaves room for differing definitions and differing conventions. In a pure math setting, there are indeed numerous definitions for dimension. But all of them focus on what the limit of this dimension is at closer and closer
zoom levels. You can think of that in terms of the plot as the limit of this slope, as you move
farther and farther to the right. So for a purely geometric shape to be a genuine fractal, it has to continue looking
rough, even as you zoom in infinitely far. But in a more applied setting, like looking at the coastline of Britain, it doesn’t
really make sense to talk about the limit as you zoom in more and more. I mean, at some point, you’d just be hitting atoms.

Instead, what you do is you look at a sufficiently wide range of scales, from very
zoomed out up to very zoomed in. And compute the dimension at each one. And in this more applied setting, a shape is typically considered to be a fractal
only when the measured dimension stays approximately constant, even across multiple
different scales. For example, the coastline of Britain doesn’t just look 1.21-dimensional at a
distance. Even if you zoom in by a factor of a thousand, the level of roughness is still around
1.21. That right there is the sense in which many shapes from nature actually are
self-similar, albeit not perfect self-similarity.

Perfectly self-similar shapes do play an important role in fractal geometry. What they give us are simple-to-describe low-information examples of this phenomenon
of roughness. Roughness that persists at many different scales and at arbitrarily close scales. And that’s important! It gives us the primitive tools for modeling these fractal phenomena. But I think it’s also important not to view them as the prototypical examples of
fractals. Since fractals in general actually have a lot more character to them.

I really do think that this is one of those ideas where once you learn it, it makes
you start looking at the world completely differently. What this number is, what this fractional dimension gives us, is a quantitative way
to describe roughness. For example, the coastline of Norway is about 1.52-dimensional, which is a numerical
away to communicate the fact that it’s way more jaggedy than Britain’s
coastline. The surface of a calm ocean might have a fractal dimension only barely above two,
while a stormy one might have a dimension closer to 2.3. In fact, fractal dimension doesn’t just arise frequently in nature. It seems to be the core differentiator between objects that arise naturally and those
that are just man-made. For the final animation here, I have a certain whimsical 𝜋-creature fractal I wanna
show you.