This example draws a colorized Mandelbrot image on screen using Qt4 widgets.
The example uses a simple class to abstract complex numbers. In principle, one could just use std::complex, if it would perform well enough. But especially the norm function is very slow for scalar float/double. Also, complex multiplication is correctly implemented to handle NaN and infinity. This is not required for Mandelbrot as these special cases will not occur. Additionally, the provided complex abstraction stores the square of the real and imaginary parts to help the compiler in optimizing the code as good as possible.
Mandelbrot uses the function z = z² + c for iteration.