Bifurcation Diagram

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 \delta.
The fractal nature comes from iteratively applying a simple function, f(x) = \lambda \cdot x \cdot (1-x) with 0 \leq \lambda \leq 4, and looking at its poles.
The resulting image looks mundane at first, when looking at 0 \leq \lambda \leq 3, though the last quarter section is where the interesting things are happening (hence the image below only shows the diagram for 2 \leq \lambda \leq 4).
From \lambda = 3 on, the diagram bifurcates, always doubling its number of poles, until it enters the beautiful realm of chaos and fractals.

Bifurcation Diagram lambda in range [2; 4]
For more on bifurcation, fractals and \delta, I refer to this Wikipedia entry and WolframMathworld.


# 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")
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s