% Driver for comparing different Adams-Bashforth formulae
% we use for reference 5.6.3 a. YOU NEED TO CHANGE THIS TO 5.6.2 a and b.
function drvab
fprintf('-------------- 5.6.3 a ------------------\n');
n=10; a=1; b=2; f = @(t,y) y/t - (y/t)^2; y0=1;
y = @(t) t./(1+log(t));
compareab(a,b,n,y0,f,y);

% NO NEED TO CHANGE BELOW THIS LINE
function compareab(a,b,n,y0,f,y)
yab2 = ab2(a,b,n,y0,f);
yab3 = ab3(a,b,n,y0,f);
yab4 = ab4(a,b,n,y0,f);
yab5 = ab5(a,b,n,y0,f);
ytrue=y(a+(0:n)*(b-a)/n);
fprintf('%4s %10s %10s %10s %10s %10s\n','t','AB2','AB3','AB4','AB5','True');
for i=2:n+1,
 fprintf('%4.1f %10.7f %10.7f %10.7f %10.7f %10.7f\n', ...
         a+(i-1)*(b-a)/n,yab2(i),yab3(i),yab4(i),yab5(i),ytrue(i));
end;

% Sample output:
%
% >> drvab
% -------------- 5.6.3 a ------------------
%    t        AB2        AB3        AB4        AB5       True
%  1.1  1.0042815  1.0042815  1.0042815  1.0042815  1.0042817
%  1.2  1.0161982  1.0149520  1.0149520  1.0149520  1.0149523
%  1.3  1.0316821  1.0293579  1.0298133  1.0298133  1.0298137
%  1.4  1.0497665  1.0468730  1.0477278  1.0475336  1.0475339
%  1.5  1.0697141  1.0664788  1.0675362  1.0671695  1.0672624
%  1.6  1.0910204  1.0875837  1.0887567  1.0883045  1.0884327
%  1.7  1.1133294  1.1097691  1.1109994  1.1105036  1.1106551
%  1.8  1.1363845  1.1327465  1.1340093  1.1334967  1.1336536
%  1.9  1.1599973  1.1563092  1.1575899  1.1570668  1.1572284
%  2.0  1.1840272  1.1803057  1.1815967  1.1810689  1.1812322

