Newton fractals

Another interesting set of fractals, are Newton fractals. Newton fractals are created by applying Newton's method to complex function $f(z)$. The method uses the iterated equation $$ z_{n+1} = z - \frac{f(z)}{f'(z)}. $$ If we want to apply Newton's method, we also need to find the derivative of the function $f(z)$. Since Newton's method is used to find the zero's of a function, if we repeatedly apply it to a point $z$, then $f(z_{n\rightarrow\infty}) = 0$. Note that not every point wil converge to a root, they could also end up in a cycle.

If we have the function $f(z) = z^3 - 1$, then the derivative is $f'(z) = 3z^2$. This function has three roots. If we apply Newton's method for all the points in the plane $[-1, 1]\times[-1, 1]$, then each of these points will end up at one of those three roots. We can then visualize the result by giving the resulting pixel value a color. In this case the color is determined by looking at the angle of the root, and then get a color from a color map. The color map used in this example is hsv2rgb(angle + 0.1, 1, 1).

Plot of $\textrm{arg}(z)$ of $f : z \rightarrow z^3-1$.

It took a few attempts to get this image. The biggest error I made, was using a function that has only 1, or 2 roots. This simply results in an image with only one, or two colors.

Relaxed Newton's method

We can modify the method by adding a relaxation parameter $R$ to it. This is a real value that is used to decrease/increase the step size. The relaxed Newton's method is $$ z_{n+1} = z_n - R\cdot\frac{f(z)}{(f'(z)}. $$ If we then let the value of R animate between $[0.2, 2.2]$, we can see what the effect of this relaxation parameter is. Press play in the shader below, to see the animation.

Generalized Newton's method

Another thing we can do is generalize the method. This can be done by adding a complex number $a$ to the method: $$ z_{n+1} = z_n - a\cdot\frac{f(z)}{f'(z)}. $$ If we then let $\Re(z)$ and $\Im(z)$ animate between the values $[-1, 1]$, in this case with a Lissajous curve, we can see the effect $a$ has on the method. Press play in the shader below to see the animation.

Using a different color map

Instead of using the HSV color map, which gives us a rainbow based on the angle of the complex number, we are going to look at the magnitude of the complex number, which is $|z|$. We will also use the magma color map from matplotlib, which is created by Mattz and available on ShaderToy. I have slightly modified the color map, because I wanted it to wrap at the edges, instead of having a discontinuity.

Because we want to loop our color map, we will only use the fractional part of $|z|$.

Images

This section contains a few images of different Newton fractals rendered with the color map.

Plot of $|z|$ of $f : z \rightarrow z^3 - 1$ with $a=(0.04352, 0.300609)$.

References