Where Zn and C are complex numbers. The program iterates this equation until the magnitude of Zn is at least 2 or the program performs a maximum number of iterations.
That example tracks the numbers' real and imaginary parts in separate variables. This example uses a Complex class to manage the complex numbers more easily and intuitively. The following code shows the program's main loop.
Complex Z = Z0; Complex C = new Complex(ReaC, ImaC); int clr = 1; while ((clr < MaxIterations) && (Z.MagnitudeSquared < MAX_MAG_SQUARED)) { // Calculate Z(clr). Z = Z * Z + C; clr++; }
Comments