is originally set to the pixel coordinates for (int iteration = 0; iteration < maxIteration; iteration++;) { z -= cdiv(Function(z), Derivative(z)); //cdiv is a function for dividing complex numbers float tolerance = 0.000001; for (int i = 0; i < roots.Length; i++) { float2 difference = z - roots[i]; //If the current iteration is close enough to a root, color the pixel. if (abs(difference.x) < tolerance && abs (difference.y) < tolerance) { return colors[i]; //Return the color corresponding to the root } } } return black; //If no solution is found } See also Julia set Mandelbrot set References Further reading J. H. Hubbard, D. Schleicher, S. Sutherland: How to Find All Roots of Complex Polynomials by Newton's Method'', Inventiones Mathematicae vol. 146 (2001) – with a discussion of the global structure of Newton fractals On the Number of Iterations for Newton's Method by Dierk Schleicher July 21, 2000 Newton's Method as a Dynamical System by Johannes Rueckert Newton's Fractal (which Newton knew nothing about) by 3Blue1Brown, along with an interactive demonstration of the fractal on his website, and the source code for the demonstration Numerical analysis Fractals