Benoît Mandelbrot

Born in 1924, died in 2010.Source: Wikipedia
Interested in roughness and irregularities seen in nature:
  • Traditional geometrical shapes (e.g. circle, line) are perfectly smooth
  • Searched for simple geometrical equations that would exhibit roughness
Established fractal geometry
  • Rough/fragmented geometric shapes
  • Self-similarity at all scales: zoom in on a small area and you can find the original shape in it.

The Applet

Click on this image to start the applet. The source code can be downloaded here.

Mandelbrot Applet

Mandelbrot Set: Definition

The Mandelbrot set is a set of complex numbers (c) that meet the following condition:

Zn(c) ≠ ∞  as n →∞

The function Zn is defined as follows:

  • Start by setting n=0
  • Initial value:        Z0 = c
  • Compute:            Zn+1 = Zn2 + c  (keep repeating this, incrementing n)
  • Test whether Zn goes to infinity as n goes to infinity

The Mandelbrot Set is self-similar at all scales:

  • Zoom in on areas to find small sections that look like the original shape; can zoom in further on those.

Practicalities

Computers aren’t good with infinity!

  • It has been shown that if Zn > 2, it will tend to infinity
  • We can compute Zn up to a maximum of some value such as n=100, and see if it exceeds 2 during that time
  • As you zoom into smaller areas, need to increase n

Complex numbers have two parts (real, imaginary)

  • Plot real part on X axis and imaginary part on Y axis
  • We can just treat these as two separate numbers

Square of a complex number:

  • If (a,b) is a complex number, then its square is (a2-b2, 2ab)

A commonly plotted area is from (-2,-1.5) to (1,1.5).

Plotting the Mandelbrot Set

Loop over all points in a graphics area.

For each point:

  • Rescale it to the point on the complex plane that we are plotting
  • If it’s a member of the Mandelbrot set, give it a fixed colour
  • If it’s not, colour it according the value n where it reached Zn > 2
  • To set a pixel to a colour in the applet, draw line 1 pixel long

Colouring:

  • I use blue for the members of the set
  • I give other points a hue in the range 0-0.5, which is along the colour spectrum red-orange-yellow-green.

Applet Features

JLabel :

  • Static text items

JTextField:

  • Editable items

JButton:

  • Plot and Reset buttons

ActionListener:

  • One for each button: implement actionPerformed

FocusListener:

  • One for each JTextField: implement focusLost
  • When focus is lost on a position textbox, it has been edited, so parse their values next time Plot is pressed
  • When focus is lost on Iterations textbox, it has been edited, so parse its value

MouseInputAdapter:

  • Attached to applet overall
  • mouseMoved: update mouse position textbox
  • mouseDragged: first, record start position, then record current position
  • mouseReleased: parse positions and repaint.

Feedback & Comments

To send me comments, feedback, bug reports or suggestions for changes, contact me by This email address is being protected from spambots. You need JavaScript enabled to view it. or twitter .