Help! Bifurcation diagram for difference equation

Hello everyone! I need help figuring out how to plot a bifurcation diagram when dealing with difference equations. I tried following the indications on the page http://www.math.le.ac.uk/people/rld8/ma1251/lab3.html, but I cannot figure out what I'm doing wrong. This is what I wrote:
clear all;
close all;
Npre=100;
Nplot=200;
x = zeros(Nplot,1);
for lambda = 0:0.01:5
x(1) = 2.95;
x(2)=x(1)+0.2;
x(3)=x(1)-0.2;
for i = 3:Npre
% x(i+3) = x(i+2)+0.19*100*(0.5*0.3*(3-x(i+2))-0.5*0.5*(x(i+2)-3))./(1+exp(-lambda*(2.1*((1/3)-0.01)+15*((x(i+1)-x(i))./x(i)))));
x(3)=x(3)+0.19*100*(0.5*0.3*(3-x(3))-0.5*0.5*(x(3)-3))./(1+exp(-lambda*(2.1*((1/3)-0.01)+15*((x(2)-x(1))./x(1)))));
end
for i = 1:Nplot-3
x(i+3) = x(i+2)+0.19*100*(0.5*0.3*(3-x(i+2))-0.5*0.5*(x(i+2)-3))./(1+exp(-lambda*(2.1*((1/3)-0.01)+15*((x(i+1)-x(i))./x(i)))));
end
plot(lambda*ones(Nplot,1), x, '.', 'markersize', 2);
hold on;
end
title('Bifurcation diagram');
xlabel('lambda'); ylabel('x_i');
set(gca, 'xlim', [0 5], 'ylim', [1.5 4.5]);
hold off;

8 comentarios

darova
darova el 12 de Abr. de 2020
I don't understand the question. I run your code and got this:
Can you exaplain more? Maybe a simple sketch or simething?
Thank you darova for your help! I am getting the same figure as you, but my aim is actually to replicate the following plot:
It is clear that there are some mistakes in the code... It is my first time trying to plot a bifurcation diagram on my own, any advice is well taken!! Thank you again.
darova
darova el 12 de Abr. de 2020
Can you attach your original eqaations?
I have somer problem with the link you gave
The original equation is the following:
function[x]=time_series(alpha, beta, lambda, gamma, Num, gf, gc, w, F, r, D, N, x0)
alpha=2.1;
beta=15;
D=1;
F=3;
r=0.01;
Num=100;
gf=0.5;
gc=0.3;
lambda=1;
gamma=0.19;
w=0.5;
x=zeros(N,1);
x(1)=x0;
x(2)=x0+0.2;
x(3)=x0-0.2;
for i=1:N-3
x(i+3)=x(i+2)+gamma*Num*((w*gf*(F-x(i+2))+(1-w)*gc*(x(i+2)-F))./(1+exp(-lambda*(alpha*((D/F)-r)+beta*((x(i+1)-x(i))./x(i))))));
end
I forgot, in the above code N=1100, where the first 1000 observations are just to lose the effect of the initial condition, which is x0=2.95
darova
darova el 12 de Abr. de 2020
There is too much text! I understand this: you have diff equation and want to draw something
Where is the diff equation? Can you show? What needs to be done to draw bifurcation diagram?
This is the difference equation:
x(i+3)=x(i+2)+gamma*Num*((w*gf*(F-x(i+2))+(1-w)*gc*(x(i+2)-F))./(1+exp(-lambda*(alpha*((D/F)-r)+beta*((x(i+1)-x(i))./x(i))))))
As I understood correctly, to draw a bifurcation diagram we need to create a loop to show the values approached asymptotically of some system of equations or map as a function of a bifurcation-changing parameter (lambda, in my case). The solid line in the picture I attached are the stable values of the system (so the system is stable until lambda approaches lambda_T). After lambda_t the system becomes unstable, first through period-doubling bifurcations, then reaching chaotic behavior.
Thank you again for your help.
Try to change lambda value
Don't forget about limits
set(gca, 'xlim', [0 5], 'ylim', [1.5 4.5]);

Iniciar sesión para comentar.

Respuestas (0)

Preguntada:

el 12 de Abr. de 2020

Comentada:

el 12 de Abr. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by