%Sec2.7 P108 No.1
%Initialization
h = 0.1;            %stepsize (can ben changed to 0.05,0.025 for (b),(c))
tf = 0.4;           %tf is the final time.
y0 = 1;             %initial value.
t = [0:h:tf];

n = length(t);      %Number of steps
y = zeros(n,1);
y(1) = y0;        
for i = 2:n
   f = 3 + t(i-1) - y(i-1); %f(t_n,y_n)
   y(i)= y(i-1) + f*h;      %y_(n+1)=y_n + f(t_n,y_n)*h 
end
y
%You may also compute the exact solution in a similar way.
