% Framåt Euler exempel


f=@(t,y) -8*t*y;
N=250
h=0.05;
tv=[];
yv=[];
t=0;
y=1;

for i=1:N
   y=y+h*f(t,y); 
   t=t+h;
   yv=[yv;y];
   tv=[tv;t];
end

clf;
plot(tv,yv,'*-');
hold on;
plot(tv,exp(-4*tv.*tv),'r')

legend('Exakt losning', 'Framat Euler approx')
xlabel('t')
ylabel('y')
grid on

