![fractal time calculator fractal time calculator](https://i.pinimg.com/736x/e8/b6/38/e8b63885e2da98f08cfbc3fef4019874.jpg)
The speed of squaring and multiplication is critical because in high-precision math they are O(n^2) operations and everything else is O(n). While this isn’t truly unlimited it is close enough because fractal calculation time generally increases as the cube of the zoom level, and even on the fastest PCs available it exceeds most people’s patience between 500 and 2,000 bits of precision. Fractal eXtreme supports up to 7,680 bits of precision. All of my fractal programs have featured high-precision math routines to allow virtually unlimited zooming. However floating-point math has only about 52 bits of precision which is woefully inadequate for serious fractal exploration. When using floating-point math the speed of addition, subtraction, and multiplication are generally identical. So it’s perfect, and all we have to worry about is making sure that all of our basic operations – especially squaring and multiplication – are as fast as possible.
#Fractal time calculator code#
} Now the code is doing three multiplies per iteration, which is the minimum. It squares z.r and z.i twice each, and it multiplies by two. The code does six multiplications and at high-precisions those are very expensive. That’s correct but it’s not very efficient. With that in mind a more detailed version would be: I’m not going to review complex math, but I will point out that abs(complex) is equal to the square root of (real * real + imaginary * imaginary) and if you square both sides you can avoid the square root. Since z and c are complex numbers we have to store each one as two components and expand out operations like multiplication to multiple operations on those components. Practical considerations necessitate adding a limit to how many times the loop runs before giving up the search, but I’m going to ignore that for the sake of elegance and simplicity. If the loop never exits then the point is in the Mandelbrot set. The Mandelbrot set is calculated by setting the complex number ‘c’ to the location of the point you want to calculate and then executing the following loop:
![fractal time calculator fractal time calculator](https://saxs-igorcodedocs.readthedocs.io/en/latest/_images/Fractals4a.jpg)
This article discusses a simple algebraic improvement that gives up to a 33% speedup, and a follow-up article discusses a thread-scheduling improvement. I’ve been working on Fractal eXtreme on-and-off for years, and an important (and fun) part of working on it is optimizing the calculation of the Mandelbrot set, especially the high-precision math routines that allow deep-zooming.Īfter working on this over the course of a decade I assumed that all the easiest optimizations were done, but recently I found a couple of trivial optimizations that I had missed.