## This Python code uses the graph portion of the visual library (VPython) ## to create a bifurcation diagram for the logistic map. ## ## The points on the plot show how the long term behavior of the map ## depends on the parameter a. When the map converges to a single value, ## there will be a single line. The branching or bifurcation into more ## complex behavior is seen as a increases (with occasional reversions to ## simpler behavior.) from visual.graph import * ## Set up an empty plot mydots = gdots() ## For eacah a from 2 to 4 in steps of 0.01, plot the "attractor", that ## is, the pattern that the map settles down into. for a in arange(2,4,0.01): xA = 0.25 ## "Warm up" the variable - repeat the map a large number of times, ## without plotting. Ninitial = 100 for j in range(Ninitial): xA = a * xA * (1.-xA) ## Now plot 64 points in the map - if they are identical, they will ## appear as a single point. If the orbit has period-2, there will be ## 2 apparent points, consisting of 32 overlapping points. for k in range(64): xA = a * xA * (1.-xA) mydots.plot(pos=(a,xA)) ## plot the "population vs. a