Jump to content

The Mandelbrot Set


Recommended Posts

I recently became very interested in the Mandelbrot set after watching some videos of "Mandelbrot zoom" which are some cool and trippy videos with an incredibly profound underlying mathematical meaning. There is a very good Numberphile video that explains what the Mandelbrot set is in plain English, but I'll also do my best to do a very quick summary here.



The Mandelbrot set is the collection of all complex numbers (e.g. 1+i) denoted "c" which satisfy the condition that the function "Zn+1 = Zn^2 + c" where Z0=0 converges. In simpler terms that means that if you repeatedly square your result and add the original number then repeat infinitely many times then the answer is anything other than infinity. In the image above, the black region are areas where c converges and thus the function is stable, all other areas are unstable, and the different colors represent different degrees of instability (see chaos theory where a very infinitesimally small change in the original conditions has a drastic impact on the outcome). The reason this is so interesting is because of the shape of the Mandelbrot set itself. Not only is it a very interesting shape macroscopically, but it is a fractal and no matter how far you zoom in, it is infinitely complex, chaotic, and even recursive. The same macroscopic shape shows up repeatedly no matter how far you zoom in (though slightly distorted). I highly recommend viewing the Mandelbrot zoom video that I linked above, or any of the dozens more on YouTube.

If you would like to get some very basic intuition for why the Mandelbrot set looks the way it does, you can use this interactive tool which shows you the behavior of complex numbers when you repeatedly square them. This will not explain the shape of the Mandelbrot set exactly, but it will show you how squaring a complex number is actually just a rotational transformation in the complex plane. Because of this, when you repeatedly square a complex number that is within the Mandelbrot set, it will go around in a circle over and over while converging upon a finite value.

Although you can easily check whether a complex number is within the Mandelbrot set with a tool such as WolframAlpha, I decided to write a quick program which does that for myself. It works perfectly, but I must admit that it's slightly crude. The Mandelbrot set is bounded by a circle in the complex plane with radius 2, so any complex number which falls outside that circle is automatically not within it. However, if you choose a complex number that is within that circle, I believe it is theoretically possible that a future term will "bounce" outside the circle before coming back in and converging. An example that slightly shows what I mean is that 0.25 is in the Mandelbrot set, and the function converges to 0.5 so future terms are larger than the starting number but still converge. Similarly, it could be true that |(a,b)|<2 but |Zn|>2 for some n while a+bi still converges. Although this is possible, I can't imagine it being common or that numbers could bounce much further outside than 2. For that reason, I decided that I am reasonably certain no number will ever go outside the circle with radius 5, and thus if my program detects a term with real or imaginary component greater than 5 then c must not be within the Mandelbrot set. I have no proof that this is true, but like I said I am reasonably certain that it is. Additionally, my program only runs for the first 5000 terms because any number which does not converge should grow much much more quickly than that.

Here is the code in Perl:

#!/usr/bin/perl -w
use strict;
my($firstR, $firstI, $newR, $newI, $tempR);

print "Enter the real portion of a complex number> ";
chomp($firstR = <stdin>);
print "Enter the imaginary portion of a complex number> ";
chomp($firstI = <stdin>);

$newR = $firstR;
$newI = $firstI;
for(my $i = 0; $i < 5000; $i++){
	$tempR = $newR**2 - $newI**2 + $firstR;
	$newI = 2*$newR*$newI + $firstI;
	$newR = $tempR;
	if($newR>5 or $newI>5){
		print "(".$firstR." + ".$firstI."i) is not in the Mandelbrot set.\n";
print "(".$firstR." + ".$firstI."i) is in the Mandelbrot set!\n";

I hope you enjoyed this post and that you can now recognize the beauty of the Mandelbrot set.

Edited by Freak
  • I Like This! 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...