Real part of the complex number c
Imaginary part of the complex number c
Maximum number of iterations to perform
Threshold radius for considering a point as escaped (default: 2)
Number of iterations before escape, or maxIterations if point doesn't escape
// Check if origin is in Mandelbrot set (it is)
const originIterations = mandelbrotIteration(0, 0, 100); // Returns 100
// Check a point outside the set
const outsideIterations = mandelbrotIteration(2, 2, 100); // Returns 1
// Check an interesting boundary point
const boundaryIterations = mandelbrotIteration(-0.7269, 0.1889, 1000);
https://en.wikipedia.org/wiki/Mandelbrot_set for mathematical background
Computes the number of iterations for a point in the complex plane to escape the Mandelbrot set
Uses the standard iterative formula: z_{n+1} = z_n^2 + c, where z_0 = 0 and c = cx + i*cy The function returns when either the maximum iterations are reached (point likely in set) or when |z| exceeds the escape radius (point definitely not in set).