Digital Rangoli! (Newton fractals, actually)

This year, on the occasion of Diwali, I decided I will make Rangoli digitally!

x6 + x3 - 1 (30 iterations)

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.

Newton-Raphson Method:

Given a function f(x) and a complex number z_0, the series of numbers z_{n+1} = z_n - \frac{f(z_n)}{f'(z_n)} 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.

Colouring Criteria:

The Hue (h), Saturation (s) and Lightness(l) of any point on the graph is determined by:

h = 180\frac{\theta + \pi}{\pi}s = 0.75l = \frac{1}{2} - \frac{n}{2m}, where \theta is the argument of the root the point reaches, n is the number of steps in which the point got within \epsilon 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.

\epsilon 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.

x8 + 15x4 - 16 (30 iterations)

f(z) = z^8 + 15z^4 - 16

x8 + 15x4 - 16 (100 iterations) (zoom)

A closeup of an intricate region of the above graph.

x6 + x3 - 1 (30 iterations)

f(z) = z^6 + z^3 - 1

x3 - 2x + 2 (30 iterations)

f(z) = z^3 - 2z +2

x3 - 1 (30 iterations)

f(z) = z^3 - 1

The program is written in C++. You can find the source code here:

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

Wishing you a Happy and Safe Diwali! 🙂