MCS 275 Spring 2021 Lecture 27 - Emily Dumas
At the moment, this only contains the code I wrote during Lecture 27. In the near future I may add some explanatory text. The slides from Lecture 27 have more detail on the goals.
def g(x):
return x*x
def f(x):
return x*x-1
def orbit(func,a,n):
L = [a]
for _ in range(n):
L.append(func(L[-1]))
return L
orbit(g,2,5)
orbit(f,0,8) # 0 is in the filled Julia set
orbit(f,1,8) # 1 is in the filled Julia set
orbit(f,1.5,30)
orbit(f,2,10) # looks like 2 is not in the filled Julia set
def bounded_orbit(func,a,maxiter=10):
z = a
for _ in range(maxiter):
if abs(z) >= 2:
return False
z = func(z)
return True
bounded_orbit(f,0.5+0.2j)
import numpy as np
x = np.linspace(-1.7,1.7,1500)
y = np.linspace(-1.7,1.7,1500)
xx, yy = np.meshgrid(x,y)
zz = xx+1j*yy
def f_bounded_orbit(a):
return bounded_orbit(f,a,maxiter=150)
f_bounded_orbit(0.2+0.3j)
orbit_classification = np.vectorize(f_bounded_orbit)(zz)
from PIL import Image
img = Image.fromarray(255*(1-orbit_classification.astype("uint8")),mode="L")
img
img.save("basilica.png")