Shared2018-09-05-164906.ipynbOpen in CoCalc
Lab

1a)

format long;

function x = Updatex(r, x)
	x = r.*x.*(1-x);
end

function x = TrajLogEq(n, r, x, fig, s=0)
	x = [x, zeros(1, n-1)];
	for i = 2:n
		x(i) = Updatex(r, x(i-1));
	end
	
	if fig == 1
		plot(1:n , x + s)
		xlabel('Iteration n')
		ylabel('Population x')
	end
end

function BFDLogEq(r, x)
	hold on;
	x = 0*r + x;
	for n = 2:1000
		x = Updatex(r,x);
		if n >= 990
			scatter(r, x, 1, "k")
		end
	end
	title('Finite iteration BFD')
	xlabel('BFP r')
	ylabel('Fixed point x*')
end
n = 50;
r = 2.75;
hold on;
TrajLogEq(n, r, 0.1, 1);
TrajLogEq(n, r, 0.2, 1);

Lets look at the phase diagram of the system in the limit where xn+1=xn=xx_{n+1} = x_{n} = x xn+1=rxx(1xn) x_{n+1} = rx_{x}(1-x_{n}) x=rx(1x) x = rx(1-x) Which has root solutions of the form x=0,  x=11r x = 0, \ \ x = 1- \frac{1}{r} We can plot the fixed points (in the limit) as a function of r and check for when r = 2.75.

fixedpoint = 1-(1/2.75)

r = 0.1:0.1:4;
hold on;
plot(r, 1-1./r);
plot(r, 0*r)
xlabel('r')
ylabel('x*')
fixedpoint = 0.636363636363636

1b)

From the BFD and trajectories below we can approximate the behaviour over our BF parameter.

  • 0<r<30 < r < 3 \Rightarrow stable
  • 3<r<3.453 < r < 3.45 \Rightarrow 2 cycle
  • 3.45<r<3.543.45 < r < 3.54 \Rightarrow 4 cycle
  • 3.54<r<3.573.54 < r < 3.57 \Rightarrow 8 cycle
  • 3.57<r3.57 < r \Rightarrow Chaotic


    Graphs below are shifted.
n = 60;
for r = [2.5, 3.0, 3.2, 3.5];
	figure
	hold on;
	TrajLogEq(n, r, 0.1, 1);
	TrajLogEq(n, r, 0.2, 1,1);
end

1c)

r = 3.0, t approx 3 iterations
r = 3.2, t approx 5 iterations
r = 3.5, t approx 5 iterations

1d)

We want to model the fixed point as a function of the BFP. In order to capture cycles, we need to scatter a few iterations after the system has tended to the fixed point. See function above.

1e)

BFD

figure 1
r = 1.8:1e-4:4;
x = 0.6;
BFDLogEq(r, x)

figure 2
r = 3.45:1e-4:3.8;
x = 0.6;
BFDLogEq(r, x)

figure 3
r = 3.56:1e-4:4;
x = 0.6;
BFDLogEq(r, x)

1f)

The pitchfork BF are a good example of self sym. These occur at the cycle doubling BFPs listed above.

1g)

We see that the two trajectories are symmetric for the first few iterations before diverging. This indicated sensitivity to initial conditions.

r = 3.67;

n = 50;
figure
hold on;
TrajLogEq(n, r, 0.1, 1);
TrajLogEq(n, r, 0.1001, 1, 1);

n = 20;
figure
hold on;
TrajLogEq(n, r, 0.1, 1);
TrajLogEq(n, r, 0.1001, 1);

figure
r = 3.56:1e-4:4;
x = 0.1;
BFDLogEq(r, x)

figure
r = 3.56:1e-4:4;
x = 0.1001;
BFDLogEq(r, x)

2a)

function x = UpdatexTwo(r, x)
	x = x.*exp(r.*(1-x));
end

function x = TrajLogEqTwo(n, r, x, fig, s=0)
	x = [x, zeros(1, n-1)];
	for i = 2:n
		x(i) = UpdatexTwo(r, x(i-1));
	end
	
	if fig == 1
		plot(1:n , x + s)
		xlabel('Iteration n')
		ylabel('Population x')
	end
end

function BFDLogEqTwo(r, x)
	hold on;
	x = 0*r + x;
	for n = 2:1000
		x = UpdatexTwo(r,x);
		if n >= 990
			scatter(r, x, 1, "k")
		end
	end
	title('Finite iteration BFD')
	xlabel('BFP r')
	ylabel('Fixed point x*')
end
r = 0:5e-3:4;
x = 0.5;
BFDLogEqTwo(r,x)

From the BFD and trajectories below we can approximate the behaviour over our BF parameter.

  • 0<λ<20<\lambda<2 \Rightarrow stable
  • 2<λ<2.5252<\lambda<2.525 \Rightarrow 2 cycle
  • 2.525<λ<2.6522.525<\lambda<2.652 \Rightarrow 4 cycle
  • 2.652<λ<2.682.652<\lambda<2.68 \Rightarrow 8 cycle
  • 2.68<λ2.68<\lambda \Rightarrow Chaotic
x = 0.5;

figure 1
r = 1.9:5e-4:2.55;
BFDLogEqTwo(r,x)

figure 2
r = 2.5:5e-4:2.7;
BFDLogEqTwo(r,x)

figure 3
r = 2.65:5e-4:3;
BFDLogEqTwo(r,x)

figure 4
r = 2.7:5e-4:2.8;
BFDLogEqTwo(r,x)
x = 0.5;
n = 50;
for r = [1, 2.5, 2.6, 2.7] ;
	figure
	TrajLogEqTwo(n, r, x, 1);
end