Home > i will do these, Justincase > My first logistic bifurcation curve and a bit more

## My first logistic bifurcation curve and a bit more

I don’t know since when, but I desperately want to learn how do I make a logistic bifurcation curve. And now, I finally able to create one. I do not want to forget this ability therefore I post this post, just in case I forget.

Logistic map is one of discrete dynamical systems, represented in the following:

$x_{n+1} = \mu x_n (1-x_n)$.

It is basically a recursive sequence. It looks simple but it is highly not.When $\mu \in [0,4]$ the sequence generated will always be inside the interval [0,4].More specifically, when $\mu =2$, the sequence converges to a point. When $\mu$ is varied, does the solution still converge to some point?

In fact, when we vary $\mu$ past 3 we have the situation that is best explained through the following figure:

The figure is saying when $\mu$ is just past 3, the sequence is no longer converging to a point. This phenomena is called a period-doubling, as the sequence now tends to alternatingly approaching two points. However, this is the code to create the above figure in Matlab.

 clear; clc; a = 3:0.005:4;  %interval of parameter x0 = 0.5;       %initial condition N=500;          %number of iterations x(1) = x0;      %the first entry is the initial condition %computation of the orbit figure(3);hold on; for i=1:length(a) for j=2:N x(j) = a(i)*x(j-1)*(1-x(j-1)); end y = x(301:end); plot(a(i),y); end hold off clear

Okay, the fitst task is done. Let us now learn how to make a movie in Matlab. I choose the topic ‘coweb’ as an example. Coweb arises in our topic, which is a discrete dynamical system.

Here is the video

The coweb created in the above movie uses $\mu=3.9$. This exactly where the chaotic dynamic occurs. Therefore, we do not see any pattern there. The iteration that I used is only 90. However, we already see that the sequence makes such a complicated figure.

The code to create such a video is the following.

clc;clear; myu = 3.9; %initial parameter maxiter = 90; %maximum iteration xo = 0.4; %initial condition aviobj = avifile ( 'logistik2.avi', 'fps', 3 );%create a file logistik2.avi x = 0:0.01:1; %range of x data y1 = myu.*x.*(1-x); %range of y data to graph y=myu(x-x^2) y2 = x; %range for y data to graph y=x figure(1);hold on; %open figure window and hold on axis([0 1.1 0 1.1]) % set the y and x axis plot(x,y1); %plot the graph of y=myu(x-x^2) plot(x,y2); %plot the graph of y=x frame = getframe ( gca ); %command 1 to store what is inside figure 1 aviobj = addframe ( aviobj, frame ); %command 2 xbaru = myu.*xo.*(1-xo); z2 = 0:0.01:xbaru; z1 = xo; plot(z1,z2); frame = getframe ( gca ); aviobj = addframe ( aviobj, frame ); fprintf('the fixed point is %f',(myu-1)/myu); for i=2:maxiter if(xbaru > xo) y1 = xo:0.01:xbaru; else y1 = xbaru:0.01:xo; end y2 = xbaru; plot(y1,y2); frame = getframe ( gca ); aviobj = addframe ( aviobj, frame ); xo = xbaru; xbaru = myu.*xo.*(1-xo); if(xbaru > xo) y1 = xo:0.01:xbaru; else y1 = xbaru:0.01:xo; end y2 = xo; plot(y2,y1); frame = getframe ( gca ); aviobj = addframe ( aviobj, frame ); end hold off; H = (myu-1)/myu; fprintf('please press any key \n'); aviobj = close ( aviobj ); %pause; %close all;

However, I really really want to learn how to convert this avi video produced by Matlab to a gif image format. So if anyone know how do I do this please let me know.

1. April 1, 2012 at 7:47 pm

Hi,
Thanks a lot for sharing your code. It’s really helpful. If you please, I need to get the same picture but for the logistic map given by
x_n = ru*x_(n-1/2)*(1-x_(n-1/2)), where n = 1/2, 1,3/2,…
Any idea?

• April 4, 2012 at 12:38 pm

Hi, so glad if it is useful to you.
Your map seems challenging, can you explain more about variables r and u ?
Are there just constants and which one would you like to be varied, and what are
the initial values?

2. July 23, 2013 at 11:13 am

I think it is a bit misleading by saying: “This exactly where the chaotic dynamic occurs.” Indeed, at that value of the parameter the map is chaotic. But the map is chaotic also in other values of the parameter. You need to compute the Lyapunov exponent against the parameter to see that.

• July 23, 2013 at 12:44 pm

Hi Theo, thanks for your feedback, the computation of Lyapunov exponents will be in the next posts soon.

1. October 4, 2013 at 8:27 am