This is Java code for an application which enables visualization of fractals generated using Newton's method. It only supports simple polynomials with maximum degree of 9 with real coefficients.
Newton fractals are a visual representation of a process called the Newton's method used to find the roots (or zeroes) of a function, . This method starts with a guess and then iterates the following expression until the values either converge or fail to converge:
where is n-th guess root point, is function value at , is function's derivative value at . You use this expression like this: first you guess a possible root and define it as , then you use this expression and obtain , now you can check precision of guessed root , if satisfies you then you can claim that is root with precision . Note that you can iterate as long as you want, the more iterations the more precise root you get. However, for every polynomial of degree at least 2 there are points for which the Newton's method does not converge to any root.
The approximate value chosen at the beginning of the process, determines to which root you will eventually converge.
This method works with complex numbers, which naturally lend themselves to 2D images. A complex number can be represented as a point on a 2D plane with coordinates and , or alternatively as a pair .
If we assign each root a color, and we color each point on the complex plane based on the root to which that point converges, a Newton fractal is the result.
In this program, the number of iterations Newton's method takes to converge determines the brightness of a pixel at a particular point (the brighter pixel the faster it reaches root). Therefore the brightest pixels are root regions.
For more information on Newton fractal check Newton fractal @ Wikipedia.
The following images were generated by this program:
See the LICENSE file for license rights and limitations (MIT).