clear;

%  solving dy/dt=k*y with the Euler forward method

y0=5;
te=20;
h=3.2;
k=0.5;

y=y0; n=0;
for t=0:h:te
    true=y0*exp(k*t);
    fprintf('  time=  %12.5f  y=%12.5f  true=%12.5f  \n',t,y,true);
    n=n+1;
    yy(n)=y;
    xx(n)=t;
    tt(n)=true;
    y = y + h*k*y;
end
    plot(xx,yy,xx,tt);


