% Driver for Predictor Corrector method
% We use for reference 5.6.7 a. 
% YOU NEED TO CHANGE THIS TO 5.6.6 a,b

function drvpc
fprintf('-------------- 5.6.7 a ------------------\n');
n=10; a=1; b=2; f = @(t,y) y/t - (y/t)^2; y0=1;
y = @(t) t./(1+log(t));
comparepc(a,b,n,y0,f,y);

% NO NEED TO CHANGE BELOW THIS LINE
function comparepc(a,b,n,y0,f,y)
ypc = a4pc(a,b,n,y0,f);
ytrue=y(a+(0:n)*(b-a)/n);
fprintf('%4s %10s %10s\n','t','A4PC','True');
for i=2:n+1,
 fprintf('%4.1f %10.7f %10.7f\n', ...
         a+(i-1)*(b-a)/n,ypc(i),ytrue(i));
end;

% Sample output
%  -------------- 5.6.7 a ------------------
%     t       A4PC       True
%   1.1  1.0042815  1.0042817
%   1.2  1.0149520  1.0149523
%   1.3  1.0298133  1.0298137
%   1.4  1.0475227  1.0475339
%   1.5  1.0672462  1.0672624
%   1.6  1.0884141  1.0884327
%   1.7  1.1106352  1.1106551
%   1.8  1.1336331  1.1336536
%   1.9  1.1572076  1.1572284
%   2.0  1.1812112  1.1812322
