Monday, July 20, 2015

Let's make a Mandelbrot set!

LabKitty Academy Greal Seal
LabKitty has a dream. I dream one day all of quantum mechanics, with its hateful partial differential equations and infinite dimensional matrices and renormalizable gauge theory and whatnot, will be replaced by simple mathematics even a child can understand. Perhaps somewhere it already has. This very day, an alien physicist may well be flippering through Wikipedia and snickering.

Feynman diagrams
!, s/he snorts derisively. The puny Earthmeats have yet to discover the true path.

The secret of the Old One, as Einstein put it.



Hypothesis: Quantum mechanics is wrong, and it only works so well because this square theoretical peg has been pounded into the round hole of experimental results for some five score years by the smartest cats on the planet. What is the correct version? If I knew that I would be in Stockholm collecting my Nobel prize and government sponsored hookers. Then I would tour the world and put my feet up on your desk and you would have to take it. (I believe it was Leon Lederman who said the best thing about winning a Nobel prize is you can go to someone's office and put your feet up on their desk and they have to take it. A candid glimpse into the twisted psyche of academics.)

I cannot show you the true path, but I can show you an analogy. Consider the Mandelbrot set.

mandelbrot set

If you did not know how the Mandelbrot set (M) is generated, what mathematics might you conclude are behind it? Imagine the set is an experimental result. Something measured in the laboratory. The very first measurement would be crude -- just a circle, say -- for that is the natural progression of experimental science. A circle is easy enough for mathematics to describe; using set notation we conclude:

  M = { (x,y) : x2 + y2 < r }.

However, the apparatus gets better. New data come to light.

We discover the Mandelbrot set is not one circle; it is two -- a smaller next to a larger. We update our mathematics to reflect this information:

  M =   { (x,y) : x2 + y2 < r1 } ⋃ { (x-x0)2 + y2 < r2 }

Then, more results arrive. The experimentalists show the circles are not circles; they appear to be cardioids. Not a problem -- our mathematics can handle that. But there's still more. Smaller circles must be added above and below. M is updated. The latest experiment reveals a tenuous thread to the left. M is updated again. Higher resolution images show spirals peeling off in all directions. Cat's above! Is there no end to this damn thing?

Fast forward a hundred years and our description of M is exquisitely accurate but so complicated it takes four years of physics undergraduate education and another five of graduate school to understand it. The journals overflow with analytic results and computational tricks. The libraries contain oppressive walls of textbooks. The bookstores fill with popular accounts aimed at the nonspecialist. YouTube videos. TED talks. Khan Academy.

Then, one day, Benoit Mandelbrot announces M is just an iterated map in the complex plane. Simplicity itself. Everything we thought we knew is made obsolete. The complexity vanishes.

This is the true path. The secret of the Old One, as Einstein put it.

Let's Make a Mandelbrot Set

To generate the Mandelbrot set, you place a grid over the complex plane, and at a given grid point (call it "c") you iterate the equation z= z2 + c, starting with z = c. If | z | remains finite no matter how many times you perform the iteration, then c is in the set and you fill in that grid box in black. If the iteration blows up, then c is not in the set and you leave the grid box empty. (I should be more careful with my terminology. You test a grid point -- a complex number -- but you fill in a grid box. The grid point is the lower left corner of the associated grid box. Make the grid fine enough and the difference is negligible.)

Have some Matlab:

grid_count = 50;
max_iter = 50;
m = zeros(grid_count);
delta = 2.0/grid_count;

for row = 1 : grid_count
    x = -1.5 + delta * row;
    for col = 1 : grid_count
        y = -1.0 + delta * col;   
        c = x + i*y;
        z = c;
        mflag = 1;
        for iter = 1:max_iter
            z = z*z + c;
            if (abs(z)>c & abs(z) > 2)
                mflag = 0;
                break;
            end
        end
        m(col,row) = mflag;
    end
end

pcolor(m);
colormap gray;
axis square;

The result looks like this:

four mandelbrot sets

From left to right, the plots use a 10x10, 20x20, 50x50 and 100x100 grid. I left the grid off the last picture because it would have been a mess.

If you want color, then for the points that blow up (i.e., the values of c that aren't in the set) you note how many iterations it took to blow up. Clearly, no finite number of iterations gets to infinity, but there's some fancy theorem that states if the iteration ever exceeds max(c,2) in modulus, you can stop: it's not in the set. We call the number of iterations it took before the jig was up the escape number of the point. You color each grid box according to its escape number.

I leave this as an exercise for the reader.

LabKitty skull logo

No comments:

Post a Comment