%Numerical Analysis machine problem 1.17
y = 1-exp(-1);
for i = 1:20
    y = i*y - exp(-1);
    %fprintf('Y = %1.15e \n',y)
end
Y = zeros(21,5);
for i = 1:5
    for k = 21:-1:2
        N = 20+2*i;
        Y(k-1,i) = ((Y(k,i) + exp(-1))/(k-1))^N;
    end
end
e = zeros(21,4);
for i = 1:4
    e(:,i) = max(abs((Y(:,i+1)-Y(:,i))./Y(:,i+1)));
end
e
fprintf('Last column of Y = \n')
for i = 1:21
    fprintf('%1.15e \n', Y(i,5))
end




