NOTE: This does NOT apply to perturbation theory. I'm talking in terms of just normal rendering.
We know that most points that we calculate keep oscillating between a few points (roughly) and tend towards infinity or tend towards 0. What I've found is that points that tend towards 0 (points that are in the set) just get into loops where the oscillate through a few exact points. It becomes an infinite loop. If we increase the precision of our numbers, that point may not tend towards 0, but at the precision we are rendering at, the points will always stay within the set. The program will keep calculating the same thing over and over again until it finally reaches the maximum iteration mark and the program will color the point accordingly. A much better way of doing this would be to check whether points are in a loop. Then we know with certainty that the point is in the set. The problem is that we don't know how many points the program will loop through. It could be 2 points, 4 points, 10 points, 1 point. We just don't know. We could always compare a new point calculated to all the previous points to determine whether it's the same, but that would cost a lot of memory, and it would be slow.
Instead, we can just randomly select a point, see if another point in the future equals it EXACTLY and break. Here is the code:
int randNum = 0;
random_device rand_dev;
mt19937 generator(rand_dev());
uniform_int_distribution<int> distribution(0, 6);
randNum = distribution(generator);
if (randNum == 4) {
if (mpfr_cmp(ZCoordinateReal, lastZCoordinateReal) == 0 && mpfr_cmp(ZCoordinateImaginary, lastZCoordinateImaginary) == 0) {
break;
}
mpfr_set(lastZCoordinateReal, ZCoordinateReal, MPFR_RNDN);
mpfr_set(lastZCoordinateImaginary, ZCoordinateImaginary, MPFR_RNDN);
}
This works because we know that if the exact same point is calculated twice, it must result in a loop because in Z^2+C, only Z is changing between iterations.
The reason this doesn't work with Perturbation Theory is that XSubN will change based on the iteration, so just because DeltaSubN at an iteration equal the DeltaSubN at another iteration, that doesn't mean that YSubN is the same. (Maybe you could check YSubN?)
Linkback: https://fractalforums.org/fractal-mathematics-and-new-theories/28/method-of-early-checking-whether-a-point-is-in-the-set/572/