%eks 10.4

n=4;
h=1/n;
y=zeros(n+1,1);
y(1)=1;

for i = 1:n
    y_star=(1-h)*y(i);
    y(i+1)=y(i)-h/2*(y(i)+y_star);
end

disp(y(end)-exp(-1))