Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from fractions import gcd
- import matplotlib.pyplot as plt
- from math import log
- from matplotlib import animation
- import time
- TWO_POW = 2**32
- #calculate the iterations
- def getNext(rotation,number,count):
- num = number
- exp = [0]
- for i in range(count):
- iteration = rotation*num + 1
- quotient = gcd(iteration,TWO_POW)
- exp.append(exp[-1] + log(quotient,2))
- num = iteration/quotient
- return exp
- height = 50 # number of odd numbers calculated per c*n+1 image
- window = 50 #number of iterations of c*n+1 calculated per odd number
- odds = 50 #number of different odd c values used
- oddStart = 1 #odd number from which iterations begin
- seed = 2**odds-1 #in this case we are proceeding exponentially according to an ever better approximation of -1 in the 2-adics
- #calculate the exponent cumulative sums
- arrays = [[[(1 if y in getNext(seed%(2**(l+1)),2*x+1,window) else 0) for y in range(0,window)] for x in range(height-window,height)] for l in range(odds)]
- #plot dis boi
- figure = plt.figure()
- temp = figure.add_subplot(111)
- imsh = temp.imshow(arrays[0], interpolation='bicubic',cmap='magma')
- plt.show(block=False)
- #animation loop
- for i in range(odds):
- time.sleep(0.1)
- imsh.set_array(arrays[i])
- figure.canvas.draw()
- #code for saving
- #figureForSaving = plt.gcf()
- #figureForSaving.set_size_inches(5, 5)
- #plt.savefig("myplot{}.png".format(i%odds), dpi = 100)
- plt.show()
Add Comment
Please, Sign In to add comment