# Draw some orbits
def draw_orbit(p, c, iters):
"""Compute list of points in orbit of point p under f(z)=z^2+c.
Up to iters iterations."""
list_orbit = [p] # list of points in orbit
z = p # z will keep track of point in the orbit
for n in range(iters):
z = z*z + c # apply one additional iterate
list_orbit.append(z)
return list_orbit
draw_orbit(complex(0.5,0),complex(0,0),5)
# f(z)=z^2, orbit of i
list_plot(draw_orbit(complex(0,1),complex(0,0),5))
draw_orbit(complex(1,0),complex(0,0),5)
# 1 is not an attracting fixed point; points nearby get pushed away
list_plot(draw_orbit(complex(1.1,0),complex(0,0),5))
# 0 is a fixed point, and is attracting
list_plot(draw_orbit(complex(-0.11,-0.4),complex(0,0),6))
# find fixed points for f(z)=z^2 + c
# solve z^2+c = z for z
# z^2-z+c = 0
def find_fp(c):
p1 = (1+sqrt(1-4*c))/2
p2 = (1-sqrt(1-4*c))/2
return (p1,p2)
(p1,p2) = find_fp(1.0); (p1,p2)
# confirm to make sure p1 is actually fixed
(0.500000000000000 + 0.866025403784439*I)^2 + 1.0
# test whether f.p. is attracting
# for z^2 + 1
# compute multiplier abs(f'(p)) = abs(2p)
abs(2*p1)
# since this is >= 1, the fp is not attracting
abs(2*p2)
# also not attracting
# neither f.p. of z^2+1 is attracting
(p1,p2) = find_fp(0); (p1,p2)
(abs(2*p1), abs(2*p2))
# we already know 0 is an attracting fp for z^2
# try f(z) = z^2 + c for c small
(p1,p2)=find_fp(complex(0.1,0.06))
(abs(2*p1), abs(2*p2))
# p2 is attracting
# try f(z) = z^2 + c for c somewhat bigger
(p1,p2)=find_fp(complex(0.2499999,0))
(abs(2*p1), abs(2*p2))
# p2 is attracting
# try f(z) = z^2 + c for c somewhat bigger
(p1,p2)=find_fp(complex(0.25,0))
(abs(2*p1), abs(2*p2))
# p2 is no longer attracting
# correspond to cusp of main cardiod of mandlebrot
# try f(z) = z^2 + c for c somewhat bigger
(p1,p2)=find_fp(complex(0.26,0))
(abs(2*p1), abs(2*p2))
# p2 is no longer attracting
# outside of main cardiod, still have two f.p.
# but neither is attracting
(p1,p2)=find_fp(complex(0,1.5))
(abs(2*p1), abs(2*p2))
# p2 is no longer attracting
# outside of main cardiod, still have two f.p.
# but neither is attracting
(p1,p2)=find_fp(complex(0,-1.3))
(abs(2*p1), abs(2*p2))
# p2 is no longer attracting
# Upshot: main cardiod of Mandlebrot set
# (the biggest heart-shaped region)
# parametrizes those f_c(z) that have an attracting fixed point.