I am trying to plot the Newton's Basins of Attraction for the polynomial z^3-1
using python.
I am using Newton-Raphson Iterative method to plot the graph.
Till now, I am able to plot this:
What I want to generate is something like this:
Could someone please suggest how can I do it?
Update 1
After including the initial points (which I had mistakenly omitted):
Update 2
Here is the code for the Newton-Raphson loop. Is there any error in the code that causes the slow operation?
def newtonraphson(z):
if z == 0:
return False
z1 = 0
z2 = z
tolerance = 1.0e-12
while True:
z1 = z2
z2 = z1 - function(z1)/derivative(z1)
if abs((z2 - z1).a) < tolerance:
break
return z2