# One badass fucking fractalJune 24, 2009 7:13 AM   Subscribe

I’m fascinated by the Mandelbrot Set but I don’t understand the math behind it. Can you help?

Due to general high school goofoffery, a lack of higher education, and absolutely no need for anything beyond multiplication in my adult life, the concepts behind the Mandelbrot set are totally lost on me. I understand it’s a relatively simple concept, but things like The Complex Plane, polynomials and imaginary/real numbers are not in my math vocabulary.

I’ve looked through the wikipedia article but it only confused me further.

I could really use one of the following:

An in-thread explanation of the Mandelbrot set that, say, an eight grader can understand.

A link to an off-site guide that explains things clearly and assumes very little math background.

A roadmap that I can use to work up to concepts I need to understand it. (First, take a high school algebra class, then learn basic geometry, then…)

I understand what fractals are, I’m relatively smart and I grasp concepts pretty quickly as long as they’re explained properly. Thank you.
posted by bondcliff to Education (22 answers total) 42 users marked this as a favorite

You know how when you hook a video camera to a TV screen, and then aim it at the TV, and it makes that long looping tunnel deal that keeps feeding itself? Or when a microphone picks up its own sound and creates a feedback squeal?

Mathematically, that's what the the Mandelbrot set is - a simple formula that keeps feeding back on itself (iterating) over and over. The function's result feeds the function itself, in an iterative loop

I got both of these from James Gleick's Chaos.
posted by jquinby at 7:16 AM on June 24, 2009 [2 favorites]

I have a little booklet that I kept that came free with an issue of an Amiga magazine (I think it was Amiga Shopper :P ) many years ago. It's only about 8 pages long but it explained it well enough to me that I was able to knock together my own set generator in Basic.

If you'd like it, drop me a PM and I'll scan it in for you although I imagine there are some other easy resources out on the web somewhere that other people might find but this might be a reasonable fallback if nothing else helps!
posted by sunkzero at 7:23 AM on June 24, 2009 [1 favorite]

Mandlebrot says repeatedly in his book the Misbehavior of Markets that the math behind fractal geometry is rather abstruse; therefore, I don't know how one could explain it at an eighth grade level.

His comments about its difficulty were made in comparing his mathematical background to what he thinks the mathematical background of financial theorists and practitioners is.

That said, he does an excellent job of explaining the application of fractal geometry to the financial markets in the aforementioned book, and the mathematical and statistical concepts that he does discuss are explained clearly and simply. He does not, however, explain much of the esoteric math to which he repeatedly refers.
posted by dfriedman at 7:23 AM on June 24, 2009

The arithmetic is pretty simple and if you can work through a few iterations of a point on paper it will give you better insight.

First off, I'm going to hope that Cartesian coordinates are in your vocabulary - x and y coordinates in other words. Every point in the set (and outside it) has an x and a y coordinate that gives its position on your screen.

What the complex plane is is simply a conversion of that (x,y) coordinate to a single number x+(i y). By 'i y' I mean i times y, the times symbol is just left out in higher level maths by convention and because it's everywhere, but I'll use * later on to be more explicit and to avoid confusion with x.

i is the basic 'imaginary' number, a thing that has nothing to do with being imaginary but is very different from ordinary numbers, simply because if you square an imaginary number you get a negative number. Basically
i i = -1

To make a Mandelbrot set you work with the following process
z <- (z * z) + c
You start off taking z = 0 and c = x + i*y - your coordinate in other words. You then put the result in z and repeat the process, keeping c the same.

A point is in the Mandelbrot set if the value of z never goes to infinity, and it is outside the set if it does. (The colouring you'll often see is how quickly z gets outside the circle of radius 2, when you know can prove relatively easily will go to infinity)

You can try taking a few values of c and seeing how this works - you just have to remember to group up terms that have an i in, and convert any pair of i's into -1.

So say we started with c = 0.1 + 0.2 i, and z = 0
At the first step z becomes 0.1 + 0.2 i
At the second, z*z is (0.1+0.2 i)*(0.1+0.2 i) = 0.01+0.04 i + 0.04 i * i = 0.01 - 0.04 + 0.04 i = -0.03 +0.04 i, and then we add on c again to get z = 0.97 + 0.24 i for the next loop round.

The process is pretty simple, the only weird bit is keeping track of all the i's and remembering to convert the pairs of i's to -1.
posted by edd at 7:28 AM on June 24, 2009 [5 favorites]

Response by poster: Mandlebrot says repeatedly in his book the Misbehavior of Markets that the math behind fractal geometry is rather abstruse

That's what I was afraid of. If I've been misled, and the concepts cannot be understood easily without a solid background in higher math, I don't mind being told that. I hope I didn't ask the math equivalent of "I'm a couch potato and I want to run a marathon next weekend. Tell me what I should do."

Still, I've seen some amazing answers to complex questions on AskMe, so I figured it wouldn't hurt to ask.

sunkzero,: thanks for the offer. Let's see how the thread goes but I may just take you up on that.
posted by bondcliff at 7:31 AM on June 24, 2009

I would still recommend that book if you're interested in reading about one application of fractal geometry.

It just won't give you much of an understanding of the math behind it, because, as I say, he doesn't explain the math. FWIW, he does explain why he thinks the math behind most modern financial theory is wrong, but that's not really relevant to the topic here.
posted by dfriedman at 7:35 AM on June 24, 2009

Considering how amazing the Mandelbrot set is, it's generation is remarkable simple. But it still is a bit complicated to explain, especially without pictures, but I'll try.

The Mandelbrot set is literally a set of complex numbers (i.e. points in the complex number plane). I am hoping you know what a complex number is, but if not, just think of it as a pair of regular numbers - one for the horizontal direction and one for the vertical direction (i.e coordinates on a plane).

Each point that is INSIDE the Mandelbrot set is a complex number with a particular property. Each point that is OUTSIDE the Mandelbrot set is a complex number without that property. Let me now explain what that property is:

Take a particular complex number C, which is equal to A + i*B (if that looks unfamiliar, just think of it as a pair of coordinates A and B corresponding to a point in the complex plane).

Now consider the formula Z_new = Z*Z + C
This formula takes two complex numbers, Z and C, and returns a new "Z" value. Now, if we repeat this process by inputting Z_new back into the equation (i.e. Z_new_new = Z_new*Z_new + C) then the value of Z changes. It turns out that for certain values of C, this process repeated ad infinitum results in the size of Z growing without limit, and for some values of C, Z does not grow without limit - it remains finite.

That is the property that determines whether C is in the Mandelbrot set or not - whether or not the recursive formula Z ==> Z*Z + C results in Z diverging or converging. This simple proscription results in unbelievable (and literally infinite) complexity!!! It's incredible.

Now, in a true Mandelbrot set, there are only two colors, one of which represents C's that result in convergence (the familiar Mandelbrot pattern) and another which represents C's that do result in divergence (the rest of it - the empty space).

You may be wondering why most people draw the Mandelbrot set with lots of crazy colors. The colors that are often used represent how fast each particular C makes Z diverge. That way you get all sorts of pretty patterns even in the space that isn't actually part of the Mandelbrot Set proper.

Also, in case you're wondering how to multiply complex numbers, here's how:

C = A + i * B
Z = X + i * Y

Z_new = Z*Z + C

Z_new = (X^2 - Y^2 + A) + i * (2*X*Y + B)

Thus

X_new = X^2 - Y^2 + A
Y_new = 2*X*Y + B

Hope this made sense! The Mandelbrot set is awesome...you won't be disappointed if you delve deeper, and I don't think anyone knows how deep it goes.

PS: If you want to blow your mind again, look up "Julia set" which has to do with the convergence or divergence of each C value - each C value has its own Julia Set. It's cool.
posted by Salvor Hardin at 7:36 AM on June 24, 2009 [3 favorites]

As an aside, the Mandelbrot set is the best known set of this type, but there are many others. Many such recursive equations have their own amazing and unique fractal sets, for instance

Z = Z*Z*Z + C

Generates a nice looking kidney-shaped fractal, IIRC. It's incredible - perhaps you put it best - it's one badass fucking fractal.
posted by Salvor Hardin at 7:41 AM on June 24, 2009

I'll give this a shot...

The Mandelbrot Set is the set of complex numbers for which a certain condition is true. That condition is as follows:

c = number you want to check if it's in the Mandelbrot set or not
z = 0 (initially)

Repeatedly run the following calculation:

new Z = (old Z squared) + c

If the value of Z heads off towards infinity, then c isn't in the Mandelbrot set. But if the value of Z stays within non-infinite bounds no matter how many times you repeat this calculation, then the number c is in the Mandelbrot set.

So what does all this have to do with those lovely fractals? Those are just a graphic representation of which numbers are in the Mandelbrot set, and which are not. They are two-dimensional, rather than just a row of dots, because we are talking about complex numbers. That is, numbers which have both a "real" part (e.g. 0.5) and an "imaginary" part (e.g. 0.3 x i, where i = square root of -1). So c isn't just a real number like 0.5, it's a complex number like 0.5+0.3i

Each pixel on those lovely graphics represents one possible value of c, with the real part being the horizontal axis and the imaginary part being the vertical axis (or vice-versa). The colour of each pixel represents how fast that repeated calculation goes off to infinity -- or at least, how many times you have to run that calculation before Z gets to be very large. The black area inside the fractal is the Mandelbrot set where Z never gets very large.

The border between numbers which are in the Mandelbrot set and numbers which are not, instead of being a simple line or curve like a lot of people expected, is this wonderfully complicated fractal shape that has more and more detail the closer you examine it. And looks pretty if you draw it in colour.
posted by FishBike at 7:42 AM on June 24, 2009 [3 favorites]

First, complex numbers. You probably remember that negative numbers have no square root. After all, a negative number times itself (i.e., squared) is always a positive number, so how can it have a square root? It turns out that such a number would be pretty useful if it existed. So we can define the imaginary numbers. The most important imaginary number is i, which is defined as the square root of negative one. Accordingly, all other imaginary numbers can be defined in terms of i. For example, 4i is the same as the square root of -16.

Complex numbers are two part numbers. They have a real part and an imaginary part. So, for example, 2+3i is a complex number. 2 is the real part and 3 is the imaginary part.

So, you are familiar with the standard x-y plane (aka the Cartesian plane) that you plot functions on. It consists of two number lines at right angles to one another and points on the plane are defined as an ordered pair (x, y). Now, replace one of the real number lines with an imaginary number line that goes from -∞i to +∞i. Now you can plot complex numbers as the points (real, imaginary). For instance, our 2+3i example becomes the point (2, 3i). Because of that, and to save space, complex numbers are often written using ordered pair notation, for example, (2, 3).

The Mandelbrot set:

Now, take the set of all complex numbers (and thus points on the complex plane) and do the following:

1. Take the number, call it c.
2. Add zero to it. Call that z1
3. Square z1 and add c to it. Call that z2
4. Square z2 and add c to it. Call that z3
5. (And so on.)

Eventually, it will turn out that for some starting points the new zs aren't getting any bigger. That is, the series is bounded. Those points are in the Mandelbrot set. For other starting points, the new zs will get bigger and bigger forever. Those points are not in the Mandelbrot set.

The points in the set can be graphed on the complex plane as mentioned before. The pretty colors come from assigning different colors to points depending on certain characteristics. The most common one is how long it takes for the procedure outlined above to 'escape' (that is, how long it takes before it becomes obvious that it will grow unbounded forever). Points that are almost but not quite in the set will take a long time to escape because the series grows slowly. Points that are very far from the set will escape very quickly.

Bonus: Complex arithmetic

To actually perform the steps shown above (the squaring and adding of complex numbers), you need to know some complex arithmetic. Complex arithmetic works much like regular arithmetic.

Addition is very simple: you add the real parts together and the complex parts together. For example, given complex numbers (a,b) and (c,d): (a, b) + (c, d) = (a+c, b+d)

Multiplication is a little trickier: (a, b) * (c, d) = (ac - bd, bc + ad)

You can do subtraction and division, but you don't need them for calculating the Mandelbrot set.
posted by jedicus at 7:47 AM on June 24, 2009 [10 favorites]

It depends what you want to understand, but one big issue is that mathematicians say many many different things are measures of "dimension" merely because they satisfy some of the intuitive properties of the usual notion of dimension.
posted by jeffburdges at 7:54 AM on June 24, 2009

Best answer: One thing that might help (it helped me when I decided to code a Mandelbrot set picture generating program myself) is to reconsider the pictures you see. Forget about all the colours -- look at this one instead. Black points are "in" the set, while white points are "out" of the set.

Now, how do you figure out what is in or out? If the equation zn+1 = zn2 + c diverges (ie: the result tends to get bigger and bigger, until it eventually reaches infinity) for a given complex number (described in responses above mine), that point is "out" -- white. If it remains within a reasonable range, it's "in" -- black. The second and third paragraphs of the Wikipedia article describe pretty well how you figure that out.

How do you get colours? For the "out" points, instead of choosing white, choose a colour that represents how quickly (how many iterations of the equation) the number passed a certain large threshold.
posted by Simon Barclay at 8:21 AM on June 24, 2009 [1 favorite]

Response by poster: Many good answers so far. I marked "best" based on how well they fit into the way my brain works.

Follow up questions that will either shed more light on things or else will just further display my ignorance: When I'm zooming into the set am I just using more precise numbers? More and more decimal places? What happens, other than a total mind-fuck, when I zoom in and the pattern starts repeating, like when I suddenly see the initial shape again?
posted by bondcliff at 8:32 AM on June 24, 2009

Best answer: "Follow up questions that will either shed more light on things or else will just further display my ignorance: When I'm zooming into the set am I just using more precise numbers? More and more decimal places?"
Yes, basically. Also, for points near the edge of the set you need to keep iterating the process for longer to be sure if a point is in or out, otherwise you basically smooth out the edges. As you zoom in for more detail you generally need to increase the maximum number of iterations for a good image.

I'm not sure if there's a simple explanation for why the set is self-similar however.
posted by edd at 8:40 AM on June 24, 2009

Incidentally, all the "baby" sets are unique (except they have an identical twin on the other side of the set - it is symmetrical along the real axis, which is the one that usually goes left to right). They're also all connected to the main set by an 'umbilical cord' which is usually invisibly thin.
posted by edd at 8:42 AM on June 24, 2009

wow: this is amazing. thanks, from a bystander, for the jolt of excitement when, after reading this, i googled the mandelbrot set and zoomed in to see identical shapes repeating. i never understood the mandelbrot set. i heart metafilter!
posted by airguitar2 at 9:22 AM on June 24, 2009 [1 favorite]

I seem to recall (maybe from reading Chaos) that all this got started with a question from a student.

Newton's Method is a way of solving things where you start with your best guess at the answer, then apply Newton's Method to get a slightly better answer. You keep doing this until the answer you have is good enough.

When there are multiple correct answers, which one does Newton's Method arrive at? I think the student's question was how does the choice of the initial guess affect which of the multiple correct answers you get. It was thought that you get whichever one is closest to your initial guess.

But when drawm graphically, this turns out not to be the case (when dealing with certain equations and complex numbers, anyway). There are large regions where the answer you get is the closest one to your initial guess, but the boundaries between those regions are kind of a leafy fern-looking shape instead of a line or a curve. And if you look at the edges of that shape, it's made up of smaller and smaller versions of itself.

So this self-similarity is one of the main properties of fractal shapes. There's even a nice example picture over at Wikimedia for using Newton's Method to solve x5 − 1 = 0, where x is a complex number. I can just imagine the professor generating the first of these pictures in response to the student's question and thinking "what the hell is going on there?"
posted by FishBike at 9:37 AM on June 24, 2009

Best answer: This NOVA series won't help you understand the math in depth, but it'll blow your mind, especially the last two parts.

It's a one-hour program divided into five chapters:

Hunting the Hidden Dimension

Chapter 1: Fractal Basics
Chapter 2: The Mandelbrot Set
Chapter 3: On the Defense
Chapter 4: Fractals in the Body
Chapter 5: Nature's Fractal Nature

Here's a Q&A with Mandelbrot. He also appears throughout the program.

While watching, I kept thinking of Nick Bostrom's “Are You Living in a Computer Simulation?” Philosophical Quarterly, 2003, Vol. 53, No. 211, pp. 243-255. URL: http://www.simulation-argument.com/simulation.html:

This paper argues that at least one of the following propositions is true: (1) the human species is very likely to go extinct before reaching a “posthuman” stage; (2) any posthuman civilization is extremely unlikely to run a significant number of simulations of their evolutionary history (or variations thereof); (3) we are almost certainly living in a computer simulation. It follows that the belief that there is a significant chance that we will one day become posthumans who run ancestor-simulations is false, unless we are currently living in a simulation. A number of other consequences of this result are also discussed.
posted by foooooogasm at 9:51 AM on June 24, 2009 [10 favorites]

Yes, that example picture of Newton's Method is really freaky when you realise every point has a colour assigned to it, but no two colours ever touch as one of the other three butts in when they try....
posted by edd at 10:36 AM on June 24, 2009

Response by poster: Thanks again, everyone. I can't wait to watch that Nova special.

I've known about the set for a long time (since reading The Ghost of the Grand Banks, by Arthur C. Clarke) but it was hearing the Jonathon Coulton song Mandelbrot Set (lyrics*), and, in particular, seeing this awesome video that got me really thinking about what it all meant.

The title of this thread comes from the song.

*he admits to actually describing the Julia set, not the Mandelbrot set.
posted by bondcliff at 11:31 AM on June 24, 2009

Even though I'm in a similar situation as you regarding maths knowledge, I'll recommend watching this series of videos about the fourth dimension. Despite not being specifically about the Mandelbrot set, chapters 5 and 6 of the series do talk about it and the Julia set, with visualisations that make it easier to understand.

Even if you're satisfied with what you already know about fractals, perhaps you'll still enjoy learning the material covered in the rest of the chapters. I certainly did.
posted by Bangaioh at 3:25 PM on June 24, 2009

Without math, here's the basic idea: A transform is something which takes a point in the plane, and moves it somewhere else on the plane. If you do this multiple times with the same transform, meaning, take point A, move it to B. Then move B to C, etc, that's called "iterating" the point.

Under the Mandelbrot transform, some points will eventually be transported to infinity, some points will be transported into a "stable orbit" like A -> B -> C -> A, and some points are "fixed points" meaning that the transform moves A -> A.

Many points, under iteration, will eventually end up in either stable orbits, or on fixed points. Those are the points in the Mandelbrot set. The ones that don't end up in stable orbits or fixed points are not in the set.

At the edge of the set is a large amount of uncertainty, meaning the number of iterations it takes to decide whether a point in in or out tends toward infinity.
posted by jimfl at 9:43 PM on June 24, 2009

« Older I need new headphones - Any suggestions?   |   What does prima melior mean? Newer »