Generating the famous fractal, which can be used to model populations with various cycles, generate pseudo-random numbers and determine one of nature’s fundamental constants, the Feigenbaum constant .
The fractal nature comes from iteratively applying a simple function, with , and looking at its poles.
The resulting image looks mundane at first, when looking at , though the last quarter section is where the interesting things are happening (hence the image below only shows the diagram for ).
From on, the diagram bifurcates, always doubling its number of poles, until it enters the beautiful realm of chaos and fractals.
# Python 2.7.7 Code # Jonathan Frech, 24th of March 2017
# import from PIL import Image # size and iterations w, h = 10800, 7200 i = 10000 # new image img = Image.new("RGB", (w, h)) pix = img.load() # loop through image horizontally for X in range(w): # growth factor l = 2+X*2./w # initial populations x = .5 # iterate x i times for _ in range(i): # update populations x = l*x*(1-x) # draw populations at the last 1/10 of iterations # to let the population settle on the first 9/10 if _ > i*9/10: Y = int(h-x*(h-1))-1 pix[X, Y] = (255, 0, 0) # save image img.save("out.png")