The purpose of this project is to illustrate the mathematics used to identify whether or not a complex number is a member of the Mandelbrot set.
The complex number you input identifies the complex number at the lower left corner of the first quadrant. The variable side divides the first quadrant into a mesh of complex numbers. The algorithm then identifies whether the complex number at every point of the mesh is or is not a member of the Mandelbrot set.
The Mandelbrot set exists on the complex plane. A complex number is of the form (a + bi) where a is a real number and b is a real number but b is multiplied by i, the square root of -1. On the complex plane a is graphed along the horizontal axis and bi along the vertical axis. Therefore every complex number is mapped to a unique point on the complex plane.
The working equation is z -> (z x z) + c where z and c are complex numbers. The algorithm for testing if z is a member of the Mandelbrot set requires the multiplication of two complex numbers (z x z) and the addition of two complex numbers (z x z) + c.
Definitions for the Addition and Multiplication of Complex Numbers
Addition of complex numbers: (a + bi) + (c + di) = ((a + c) + (b + d)i)
Example: (3 + 4i) + (5 - 2i) = (3 + 5) + (4 - 2)i = 8 + 2i
Multiplication of complex numbers: (a + bi) x (c + di) = ac + bci +
adi + bd(i x i)
But (i x i) = -1. Therefore, ac + bci + adi + bdi2 = ((ac - bd) +
(bc + ad)i)
Example: (5 + 3i) x (2 + 3i) = 10 + 6i + 15i + 9i2 =1+21i
You can examine the script to see how the multiplication and addition of complex numbers is handled.
Thanks to jpginn's remix for the speed improvement code.