Python 3 code ############################################################## # Sequential ordered steps of a 2D Newton's method set # generation - Polynomial f(z) = z**6+1 # (graphics module) ############################################################## # specify the absolute path of mod graphics folder (depends on user's choice) import sys sys.path.append("/Users/strumia/Library/Python/3.6/site-packages/graphics/") from graphics import* # import graphics module import numpy as np # import numpy module Radius = .5 # set escape rate threshold Cx = 0.0 # set initial x parameter shift Cy = 0.0 # set initial y parameter shift Side = .8 # set square area side M = 300 # set side number of elementary squares N = 1 # set color map scale factor Num = 256*N # set number of cycles sT=2 # set step jump win = GraphWin("Newton's method set", 5*M/3,5*M/3) # set window title win.setBackground(color_rgb(230,220,10)) # set background color def rectCol(p,q,w): # define elementary cell Rect = Rectangle(Point(int(p-sT/2),int(q-sT/2)), Point(int(p+sT/2),int(q+sT/2))) Rect.draw(win).setOutline(color_rgb(np.int(255*np.sin(w)**2), np.int(255*np.cos(w)**2),np.int(255*np.cos(w/2)**2))) # Alternative values Cx 0.1747, 0.1747 Cy -.072,-1.072 # Side 0.0015, 0.00015 Num 1024 for p in range(1,M,sT): # column scanning cycle Incy = - Side + 2*Side/M*p # define column scanning function for q in range(1,M,sT): # raw scanning cycle Incx = - Side + 2*Side/M*q # define raw scanning function x = Incx # set starting increment of x co-ordinate y = Incy # set starting increment of y co-ordinate w = 0 # set starting escape modulus value for n in range(1,Num): # recursion cycle xx = 5*x/6.0 - x*(x*x*x*x - 10*x*x*y*y +5*y*y*y*y)/(x*x+y*y)/(x*x+y*y)/(x*x+y*y)/(x*x+y*y)/(x*x+y*y)/6.0 yy = 5*y/6.0 + y*(5*x*x*x*x - 10*x*x*y*y + y*y*y*y)/(x*x+y*y)/(x*x+y*y)/(x*x+y*y)/(x*x+y*y)/(x*x+y*y)/6.0 x = xx y = yy if (x-Cx)*(x-Cx) + (y-Cy)*(y-Cy) < Radius: # escape rate condition w = n/N # escape modulus normalization rectCol(int(M/3+q),int(M/3+p),int(w)) # plot elementary cell break # interrupt cycle win.getMouse() # wait for mouse click win.close() # close window