function y = AdamsBashforth4(f,x,y0)
%
% AdamsBashforth4 uses the fourth-order Adams-Bashforth formula to solve a 
% first-order ODE in the form y' = f(x,y) subject to initial condition y0.
%
%   y = AdamsBashforth4(f,x,y0) where
%
%     f is an inline function representing f(x,y),
%     x is a vector representing the mesh points,
%     y0 is a scalar representing the initial value of y,
%  
%     y is the vector of solution estimates at the mesh points.

y(1:4) = RK4(f,x(1:4),y0);
for n = 4:length(x)-1,
    h = x(n+1)-x(n);
    y(n+1) = y(n)+h*(55*f(x(n),y(n))-59*f(x(n-1),y(n-1))+37*f(x(n-2),y(n-2))-9*f(x(n-3),y(n-3)))/24;
end
