This year, on the occasion of Diwali, I decided I will make Rangoli digitally!
I wrote a program to calculate and draw the generalized Newton fractal for a given polynomial. The fractal pattern arises from the fact that for some initial values, the Newton-Raphson method is very sensitive. This image is a map of the behaviour of each point on the complex plane (when it is chosen as starting point) under this method.
Lets go over the details part-by-part.
Given a function and a complex number , the series of numbers either converges towards a root of the function (called an attractor), or does not show convergent behaviour.
Most complex numbers produce a convergent series. Numbers in each other’s vicinity usually converge to the same root, but in some areas, nearby points reach different roots. When each complex number is coloured by the root it is attracted to, interesting plots are obtained. These plots display fractal like boundaries and similar patterns appear on zooming further.
The Hue (), Saturation () and Lightness() of any point on the graph is determined by:
= , = , = , where is the argument of the root the point reaches, n is the number of steps in which the point got within of the root and m is the maximum iterations allowed. If the point does not show convergence within the maximum number of iterations or the derivative is zero, then the point is coloured black.
Corollary: Points that have same colour, converge to the same root.
is around 0.0001 and m is 30 for the following images. The plotting area is -3.2 to +3.2 on the real axis and -1.8 to 1.8 on the imaginary axis.
Click on images to zoom in.
A closeup of an intricate region of the above graph.
The program is written in C++. You can find the source code here: https://github.com/KeshavGuptaIndia/newton_fractals/
Currently, you need to update the source code with you plotting parameters (look for comments in the main function on how to do so) and then compile it (I used Visual Studio ’15 but GCC works as well). I am working on a way to enter the parameters through a text file (like Mandelbrot Set Plotter) or through command line. Have fun with the program!
If you have any feedback, leave a comment or contact me at email@example.com.
Wishing you a Happy and Safe Diwali! 🙂