<jupyter_start><jupyter_text>Mandelbrat xdmessing around with the Mandelbrot setusing `matplotlib` to plot and animate<jupyter_code># dep for animating
!apt-get install imagemagick
from numpy import *
from matplotlib import pyplot as plt
from matplotlib.animation import FuncAnimation
def mandelbrot(a, b, threshold, exponent = 2):
    c = complex(a, b)
    z = complex(0, 0)
    
    for i in range(threshold):
        z = z**(exponent) + c
        if abs(z) > 5:
            return i
        
    return threshold - 1
fig = plt.figure(figsize=(12,12))
ax  = plt.axes()

re = linspace(-1.5, .5, 500) 
im = linspace(-1, 1, 500)

def tick(i):

  data = zeros((len(re), len(im)))

  for a in range(len(re)):
    for b in range(len(im)):
      data[a,b] = mandelbrot(re[a], im[b], 50, exponent = 2 + i/20)
  
  ax.clear()
  ax.set_xticks([])
  ax.set_yticks([])
  img = ax.imshow(data)
  return [img]

ani = FuncAnimation(
  fig      = fig,
  func     = tick,
  frames   = 100,
  interval = 30,
  blit     = True,
)
ani.save("test.gif", writer="imagemagick")
# mount drive to export results
from google.colab import drive
drive.mount('drive')
# dew it
cp test.gif drive/MyDrive/<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13609958506224065, 'fraction_numerical': 0.024896265560165973, 'mean_word_length': 3.1586206896551725, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '525834', 'license': 'WTFPL', 'n_tokens_mistral': 483, 'n_tokens_neox': 456, 'n_words': 126, 'path': 'Mandelbrot_CPU.ipynb', 'repo_name': 'patztablook22/mandelbrot', 'size': '1205'}