clear all
close all
tstar = 1;
y0 = 1/2;
f = @(t,y) y*(1-y);
tsrif = 2000;
ts = tsrif;
k = tstar/ts;
y = zeros(1,ts+1);
y(1) = y0;
t = linspace(0,tstar,ts+1);
for n = 1:ts
    y(n+1) = y(n)+k*f(t(n),y(n));
end
plot(t,y,'*')
yrif = y;
tsrange = (10:10:100);
counter = 0;
for ts = tsrange
    counter = counter+1;
    k = tstar/ts;
    y = y0;
    t = 0;
    for n = 1:ts
        y = y+k*f(t,y);
        t = t+k;
    end       
    err(counter) = abs(y-yrif(tsrif+1));
end
figure
loglog(tsrange,err,'*',tsrange,err(end)*(tsrange/tsrange(end)).^(-1))
