clear all;
close all;
r = input('Enter the bifurcation parameter r (0 < r < 4): ');
x = input('Enter the starting value x1 (0 < x1 < 1): ');
y = input('Enter the starting value y1 (0 < y1 < 1): ');
n = input('Enter the total number of iterations in a sequence n (0 < n < 50): ');
for k = 1:n % looping to settle at a stationary regime
x = r*x*(1 - x);
y = r*y*(1 - y);
end
for k = 1:n
x(k+1) = r*x(k)*(1 - x(k)); % automatic extension of the vector x from scalar
y(k+1) = r*y(k)*(1 - y(k)); % automatic extension of the vector y from scalar
end
e = abs(y - x); % e is the vector of errors that has the same structure as x and y
plot(e,'r'); % this command plots the vector e versus its index, k = 1:(n+1)
title(sprintf('Errors between two sequences of the discrete logistic map for r = %3.2f',r));
xlabel('k'); ylabel('e_k');