# Bifurcation diagram of the logistic map # FB - 201007235 import math from PIL import Image imgx = 1000 imgy = 500 image = Image.new("RGB", (imgx, imgy)) xa = 2.9 xb = 4.0 maxit = 1000 for i in range(imgx): r = xa + (xb - xa) * float(i) / (imgx - 1) x = 0.5 for j in range(maxit): x = r * x * (1 - x) if j > maxit / 2: image.putpixel((i, int(x * imgy)), (255, 255, 255)) image.save("Bifurcation.png", "PNG")