# The Mandelbrot Set

Given that I had intended this site to be more about science than maths, the number of Mandelbrot pages is slightly embarassing. However, one can learn computer science from the Mandelbrot Set, as well as maths.

So we have:

- An Introduction to the Mandelbrot Set, including a python / matplotlib example of about 40 lines.
- A faster Mandelbrot Set, using python, matplotlib and numba, and about 140 lines.
- A yet faster Mandelbrot Set, which uses TK for its graphics, rather than matplotlib. Now about 1,000 lines.
- An abandoned attempt at GTK.
- A parallelised Mandelbrot Set. Two versions given, one using numba and prange, the other python's multiprocessing module.
- A slow arbitrary precision Mandelbrot Set using fixed point arithmetic and python's long integers, with fixed point arithmetic explained.
- A slightly faster arbitrary precision Mandelbrot Set. Two versions, one using python's long integers, one using the GMP gmpy2 module.
- A yet faster arbitrary precision Mandelbrot Set showing how to call C from python. Needs a C compiler and the GMP development libraries and headers.
- A adjustable precision Mandelbrot Set calling C from python and using 128-bit ints. Needs a C compiler but does not use GMP, so is faster, whilst giving about 6 bits more precision than the double precision version.
- A adjustable precision Mandelbrot Set calling C from python and using 128-bit ints. Simulates a full 256 bit product, so is about four times slower than the above version, but adds another 60 bits of precision.
- A Mandelbrot Gallery.
- A page of Mandelbrot theory, including the effects of finite precision arithmetic.
- The Mandelbrot Set and the Logistic Map, the theory uniting these two equations.

And we have covered

- Use of TK with python
- Use of numba
- Writing a PNG file without using any libraries apart from zlib
- Use of python's multiprocessing module
- Use of fixed point arithmetic, and problems of fixed precision
- Calling C from python
- Returning numpy arrays from C to python

whilst producing lots of pleasant images.

You will find better / faster Mandelbrot Set programs on the web easily, but the point of this exercise was to learn as little whilst working with such programs. The TK codes (serial and parallel) are good enough to be useable, and if one needs arbitrary precision and can compile the mixed python/C version, then that is also almost useable.

There is plenty of scope for taking these programs further. One obvious possibility would be a program which used standard, and fast, double precision arithmetic when that was sufficient, but switched to one of the (slow) arbitrary precision versions when that became necessary.