function ShowAB()
% Plots absolute error for fixed step size Adams-Bashforth
% solution to y' = y, y(0) = 1 across [0,5].

close all
E = zeros(5,5);
for i=1:5
n = 16*2^i;
Exact = exp(-linspace(0,5,n+1)');
for d=1:5
[tvals,yvals] = FixedAB(@F1,0,1,5/n,d,n);
E(i,d) = max(abs(yvals-Exact));
end
end
semilogy([32 64 128 256 512]',E)
title('Adams-Bashforth on y''(t) = -y(t), y(0) = 1, 0<=t<=5, h = 5/n','fontsize',14)
xlabel('n (Number of Steps)','fontsize',14)
ylabel('Maximum absolute error','fontsize',14)
set(gca,'fontsize',14)
text(530,E(5,1),'d=1','fontsize',14)
text(530,E(5,2),'d=2','fontsize',14)
text(530,E(5,3),'d=3','fontsize',14)
text(530,E(5,4),'d=4','fontsize',14)
text(530,E(5,5),'d=5','fontsize',14)
axis([0 600 1e-12 1e-1])

function yp = F1(t,y)
yp = -y;