Logistic Map Bifurcation Diagram

The following is an javascript interface that shows how the bifurcation diagram for the Logistic Map is constructed. The logistic map is a discrete dynamical system, that exhibits chaotic behavior for certain values of its parameter, r. The bifurcation diagram is a numerical method for showing the asymptotic behavior of the logistic map for various values of the parameter, r.

The algorithm works as follows:

Beginning with a certain values for x and r, find n points which represent the periodic attractors of the logistic map. These periodic attractors will be approximated numerically. The algorithm involves "running off" a large number of iterations and retaining the last n as the approximate values.
  1. x = x0
  2. for i = 1 to N - n; x = f(x); loop
  3. for i = 1 to n; plot x; x = f(x); loop

Suggestions

Enter a value for r between 0 and 4 and a number of iterations N of the logistic map to use. The bifurcation diagram will plot the last n iterations of the logistic map with your chosen parameter. If the periodicity of the logistic map of with the specified parameter is greater than n, not all periodic points will be displayed so choose n wisely. It is interesting to choose n to be at least double the periodicity of the map so that you can see how closely the periodic points are estimated. You can specify a list of values for r separated by spaces (e.g. 1 2 3 3.2). You can also specify ranges of values for r in MATLAB format (e.g. 0:0.1:3 is shorthand for the list 0 0.1 0.2 ... 2.9 3).

  1. n=2, N=10000, x0=0.2, r=2 (x=1/2 is an attractive fixed point)
  2. n=8, N=10000, x0=0.2, r=3.2 (x=0.5130,0.7995 are approximate period 2 points)
    Notice: only two points are visible, even though we have asked for 8. This is evidence to suggest that the map is 2-periodic.
  3. n=8, N=10000, x0=0.2, r=3.54 (x=0.5218,0.8833,0.3648,0.8203 are approximate period 4 points)
  4. n=1000, N=50000, x0=0.2, r=4 (the chaotic attractor of this parameter value is the interval (0,1))

Refresh the browser to clear the plot.

Number of Total Iterations (N):
Number of Periodic Points (n):
Initial Point (x0):
Parameter (r):
<script type="text/javascript"> var g2 =[]; function f(x,r) { // return the value of x_n+1 return (+r)*(+x)*(1-x); } function bifiter(x0,r) { // Perform iterations of the logistic map var x = +f(x0,r); // Add data to the plot as well. g2.push([r,x]); return x; } function bifplot(n,N,x0,r) { var x = (+x0); // initial value of x is 0 // Prepare the output for reporting var msg = ''; // loop for required number of "run-off" iterations for (var i = 1; i <= N-n; i++) { x = f(x,r); } // loop for required number of iterations for (var i = 1; i <= n; i++) { x = bifiter(x,r); // append the r, i and x values for this iteration in table format msg += '<tr><td>'+r+'</td><td>'+i+'</td><td>'+x+'</td></tr>'; } // Refresh the plot... // the first data set defines the plot area // the second data set displays the data $(function () { $.plot($("#placeholder"), [ { data: [[0,0],[4,1]], lines:{show:false}}, { data: g2, points: {show: true, radius: 0.1}, color: "red", shadowSize: 0 }]); }); // return a string that includes the final n iterations in table format return msg; } function bifurcation(n, N, x0, params) { // different values of the parameter may be separated by spaces, split them into an array var paramlist = params.split(" "); // define a table header for table to insert in the msg <div> block var data = '<table border="0.5"><tr><td width="150">r</td><td width="100">i</td><td width="200">x</td></tr>'; // loop through the specified values of the parameter for (var i = 0; i < paramlist.length; i++) { // the parameter value may be specified as a MATLAB array // we'll just do it that way for any parameter // MATLAB array specifications are delimited by colons // 0:0.1:1 means 0 to 1 in steps of 0.1 var mlist = paramlist[i].split(":"); var start = +mlist[0]; // The first element in the array var end = +mlist[0]; // The last element in the array var step = 1; // The step size (MATLAB default is 1) switch (mlist.length) { case 1: // If there was only one item, we are done break; case 2: // if there are two items, the second one is the end of the array end = +mlist[1]; break; case 3: // if there are three items, the second one is the step size and // the third one is the end of the array step = +mlist[1]; end = +mlist[2]; break; default: } // loop through all of the elements of the MATLAB-style array for (var j = 0; j <= (end-start)/step; j++) // plot the asymptotic points for the current value of the parameter data += bifplot(n, N, x0, start + j*step); } // close the <table> tag data+='</table>'; // insert the asymptotic data into the msg <div> block document.getElementById("msg").innerHTML = data; } </script>