% accuracy.m: Shows accuracy of different schemes

dt = [0.15,0.1,0.075,0.05,0.025,0.01];

N = length(dt);

err_rk4 = zeros(1,N);
err_euler = zeros(1,N);
err_midp = zeros(1,N);

tMax = 150;

% compute maximum error for different cases

for k=1:N
    [tTrace,y1,yana] = euler(0,0.1,dt(k),150/dt(k));
    err_euler(k) = max(abs(y1-yana));
    [tTrace,y1,yana] = midpoint(0,0.1,dt(k),150/dt(k));
    err_midp(k) = max(abs(y1-yana));
    [tTrace,y1,yana] = rk4(0,0.1,dt(k),150/dt(k));
    err_rk4(k) = max(abs(y1-yana));
end    

loglog(dt,err_euler,dt,err_midp,dt,err_rk4);