set(0, "defaultlinelinewidth", 5);
set (0, "defaulttextfontname", "TimesNewRoman")
set (0, "defaulttextfontsize", 20)
set (0, "DefaultAxesFontName", "TimesNewRoman")
set(0, 'DefaultAxesFontSize', 20)
function y= f(x)
y=x.^2;
end
function yy= g(x)
yy=x;
end
x = linspace(-2, 2);
plot(x, f(x), x, g(x));
hold on
x0 = -0.5;
for i=1:5
if i == 1
plot([x0,x0], [0, f(x0)], '-r');
else
plot([x0, x0], [x0, f(x0)], '-r');
end
plot([x0,f(x0)], [f(x0),f(x0)], '-r');
xi = x0.^2;
x0 = xi;
end
xlim([-1, 1]);
ylim([-1, 1]);
function y= f(x)
y=cos(x);
end
function yy= g(x)
yy=x;
end
x = linspace(-2, 2);
plot(x, f(x), x, g(x));
hold on
x0 = 0.1;
for i=1:11
if i == 1
plot([x0,x0], [0, f(x0)], '-r');
else
plot([x0, x0], [x0, f(x0)], '-r');
end
plot([x0,f(x0)], [f(x0),f(x0)], '-r');
xi = f(x0);
x0 = xi;
end
xlim([0.5, 1.2]);
ylim([0, 1.2]);
function y= f(x, r)
y= r*x.*(1-x);
end
function yy=g(x)
yy= x;
end
r = 3.9;
x = linspace(0, 1);
plot(x, f(x, r), x, g(x)); xlim([0, 1]); ylim([0, r/4+0.1])
hold on
plot(1-1/r, 1-1/r, 'ok')
x0 = 0.8;
for i=1:101
if i == 1
plot([x0,x0], [0, f(x0, r)], '-r');
else
plot([x0, x0], [x0, f(x0, r)], '-r');
end
plot([x0,f(x0, r)], [f(x0, r),f(x0, r)], '-r');
xi = f(x0, r);
x0 = xi;
end
function y= f(x, r)
y= r*x.*(1-x);
end
function yy=g(x)
yy=x;
end
r = 3.5;
x0 = 0.8;
n = [1:51];
xi = zeros(size(n));
xi(1) = x0;
for i=n
if i !=1
xi(i) = f(xi(i-1), r);
end
end
plot(n, xi)
function y=f(x, r)
y= r*x.*(1-x);
end
function yy= g(x)
yy= x;
end
r = 3.4;
x = linspace(0,1,200);
plot(x, f(f(f(f(x, r),r),r),r), x, g(x), x, f(x,r)); xlim([0, 1]); ylim([0, r/4+0.1])
hold on
plot(1-1/r, 1-1/r, 'ok')
function y= f1(x, r)
y= r.*x.*(1-x);
end
function yy= f(x,r)
yy= f1(f1(x,r),r);
end
function yyy= g(x)
yyy= x;
end
r = 3.1;
x = linspace(0, 1);
plot(x, f(x, r), x, g(x)); xlim([0, 1]); ylim([0, r/4+0.1])
hold on
plot(1-1/r, 1-1/r, 'ok')
x0 = 0.8;
for i=1:101
if i == 1
plot([x0,x0], [0, f(x0, r)], '-r');
else
plot([x0, x0], [x0, f(x0, r)], '-r');
end
plot([x0,f(x0, r)], [f(x0, r),f(x0, r)], '-r');
xi = f(x0, r);
x0 = xi;
end
1;
function y= f(x, r)
y= r*x*(1-x);
end
function y=g(x)
y= x;
end
x0 = 0.8;
n = 1:1:401;
for r=linspace(3.4, 4, 200)
xi = zeros(size(n));
xi(1) = x0;
for i=n
if i!=1
xi(i) = f(xi(i-1), r);
#print("Iter: %d, x:%f\n"%(i, xi[i]))
end
end
y = xi(200:400);
plot(r*ones(size(y)), y, '.k', "markersize",2);
hold on;
end
hold off;
1;
function y= f(x, r)
y= r*x*(1-x);
end
function y=g(x)
y= x;
end
x0 = 0.8;
n = 1:1:401;
for r=linspace(3.847, 3.857, 200)
xi = zeros(size(n));
xi(1) = x0;
for i=n
if i!=1
xi(i) = f(xi(i-1), r);
#print("Iter: %d, x:%f\n"%(i, xi[i]))
end
end
y = xi(200:400);
plot(r*ones(size(y)), y, '.k', "markersize",2);
ylim([0.13, 0.18])
hold on;
end
hold off;