Guest User

Untitled

a guest
Jun 23rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. from fractions import gcd
  2. import matplotlib.pyplot as plt
  3. from math import log
  4. from matplotlib import animation
  5. import time
  6.  
  7. TWO_POW = 2**32
  8.  
  9. #calculate the iterations
  10. def getNext(rotation,number,count):
  11. num = number
  12. exp = [0]
  13. for i in range(count):
  14. iteration = rotation*num + 1
  15. quotient = gcd(iteration,TWO_POW)
  16. exp.append(exp[-1] + log(quotient,2))
  17. num = iteration/quotient
  18. return exp
  19.  
  20. height = 50 # number of odd numbers calculated per c*n+1 image
  21. window = 50 #number of iterations of c*n+1 calculated per odd number
  22. odds = 50 #number of different odd c values used
  23. oddStart = 1 #odd number from which iterations begin
  24. seed = 2**odds-1 #in this case we are proceeding exponentially according to an ever better approximation of -1 in the 2-adics
  25. #calculate the exponent cumulative sums
  26. 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)]
  27. #plot dis boi
  28. figure = plt.figure()
  29. temp = figure.add_subplot(111)
  30. imsh = temp.imshow(arrays[0], interpolation='bicubic',cmap='magma')
  31. plt.show(block=False)
  32.  
  33. #animation loop
  34. for i in range(odds):
  35. time.sleep(0.1)
  36. imsh.set_array(arrays[i])
  37. figure.canvas.draw()
  38. #code for saving
  39. #figureForSaving = plt.gcf()
  40. #figureForSaving.set_size_inches(5, 5)
  41. #plt.savefig("myplot{}.png".format(i%odds), dpi = 100)
  42.  
  43. plt.show()
Add Comment
Please, Sign In to add comment