Basic implementation of the Mandelbrot set in Python 3. This example uses Pillow for drawing the image.
According to the Wikipedia article about Mandelbrot set :
The Mandelbrot set is the set of values of c in the complex plane for which the orbit of 0 under iteration of the complex quadratic polynomial
remains bounded. For our purpose, to compute the Mandelbrot set :
- the complex plan <==> the image
- for each pixel of coordinate (i, j) in the image, using the previous recurrence relation test if it is bounded
Given a complex point, we can compute the terms at the beginning of its sequence, but may not be able to know for sure that the sequence remains bounded. Remarkably, there is a test that tells us for sure that a point is not in the set: if the magnitude of any number in the sequence ever gets to be greater than 2 (like 3 + 0i), then the sequence will surely diverge.
