% A 2-step Adams-Bashforth method
clear all

h = 0.05;
N = 20;

f = @(t,x) -2*t*x^2;

exact = @(t) 1/(1+t^2);

t(1) = 0;
x(1) = 1;
y(1) = exact(t(1));
f1 = f(t(1),x(1));

t(2) = h;
x(2) = exact(t(2));
y(2) = exact(t(2));
f2 = f(t(2),x(2));

for i=2:N
    
    x(i+1) = x(i) + h*( (3/2)*f2 - (1/2)*f1 );
    t(i+1) = t(i) + h;
    y(i+1) = exact(t(i+1));
    f1 = f2;
    f2 = f(t(i+1),x(i+1));
    
end
