% function [x] = fpoint0(g, x0, maxiter, printflag) % fpoint0 fixed point iteration % g = function to iterate % x0 = initial guess % maxiter = maximum iterations % printflag = true, display intermediate results % printflag = false, display only the final result % % This version does not use a tolerance x = x0; if printflag fprintf('%3s%19s%19s\n', 'n','x','err'); end for n = 1 : maxiter gx = g(x); err = abs(x - gx); x = gx; if printflag fprintf('%3d%19.10e%19.10e\n', n,x,err); end end end