/span></div></div></div>
<!-- 
##### SOURCE BEGIN #####
f = @(x) x.^2 - 4*x + 3.5;
r = roots([1 -4 3.5]);
%% 
% Here is the fixed point iteration. This time we keep track of the whole 
% sequence of approximations. 
%%
g = @(x) x - f(x);
x = 2.1; 
for k = 1:12
    x(k+1) = g(x(k));
end
%% 
% It's easiest to construct and plot the sequence of errors. 
%%
err = abs(x-r(1));
semilogy(err,'.-'), axis tight
xlabel('iteration'),  ylabel('error')
title('Convergence of fixed point iteration')
%% 
% It's quite clear