clear %double precision n = 20 x = zeros(n,1); x(1)=11/2; x(2)=61/11; for i=3:n x(i) = 111 - (1130 - 3000/x(i-2))/x(i-1); end figure; subplot(2,1,1); plot(x, ':rs') axis([0 n+1 0 7]); axis 'auto y' grid on title(['Double precision n=' int2str(n)]); xlabel('x(i)'); ylabel('111-(1130-3000/x(i-2))/x(i-1)'); %single precision n = 10 x = single(zeros(n,1)); x(1)=11/2; x(2)=61/11; for i=3:n x(i) = 111 - (1130 - 3000/x(i-2))/x(i-1); end subplot(2,1,2); plot(x, ':b*') axis([0 n+1 0 6]); axis 'auto y' grid on title(['Single precision n=' int2str(n)]); xlabel('x(i)'); ylabel('111-(1130-3000/x(i-2))/x(i-1)');