Created
April 22, 2017 05:58
-
-
Save wetlife/1d8a0dab7f8627377e75d593331013b2 to your computer and use it in GitHub Desktop.
This is a plot of Mandelbrot's completely incomputable set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################### | |
######## mandelplot: plot the mandelbrot set ######### | |
###################################################### | |
import numpy as np # load numerical python | |
import matplotlib.pyplot as plt # load plotting tools | |
bailout = 10**62 # bound on the number of iterations | |
radial_pixels = 512 # resolution of plot | |
sequence = [-2 + 4/radial_pixels*count for count in range(radial_pixels)] | |
image = np.zeros((radial_pixels,radial_pixels)) | |
def mandelplot(radial_pixels, bailout): | |
def mandelpixel(x, alpha): | |
z_n = 0 + 0j | |
c = x + alpha*1j | |
for n in range(bailout): | |
if abs(z_n) > 2: | |
return n | |
z_n = z_n**2 + c | |
if n == bailout - 1: | |
#print('n hit bailout; (n,z_n): ',(n,z_n)) | |
return n | |
for i_x in range(radial_pixels): | |
for i_alpha in range(radial_pixels): | |
value = mandelpixel(sequence[i_x], sequence[i_alpha]) | |
image[bailout-1-i_alpha][i_x] = value | |
figure = plt.imshow(image)#, clim=(0.4, .9)) | |
plt.set_cmap('spring') | |
plt.colorbar(orientation = 'horizontal', shrink = .5) | |
mandelplot(radial_pixels, bailout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"How can you plot a set of points that is completely incomputable?" One method is to use a convergence threshold after some number of iterations. This gist was the first thing I threw together to plot this. It could use many obvious improvements. Can you spot them? Please run this, fork this, change this to explore it, and ask me anything. I dare ya! :-)