function x=fixpoint1(g,x0,tol)
% fixpoint1 - fixed point iteration for the scalar equation x=g(x) 
% 
%   Syntax: 
%           x = fixpoint1(g,x0,tol)
%   Arguments: 
%           g - function handle pointing to a function file  
%           x0 - a real number, the initial approximation
%           tol - a tolerance 
%   Returns: 
%           x - a column vector containing the computed sequence
%   Description:
%          The program fixpoint1 uses the fixed point iteration to 
%          compute an approximate solution of the scalar equation 
%          x=g(x).  The file g.m must contain the function y=g(x).  
%          The function g:I->I must be a contraction on some closed 
%          interval I.  Then g has a unique fixed point x_exact in I. 
%          If the initial approximation x0 belongs to I, then the 
%          program computes an approximate solution x with the error
%          |x-x_exact| < tol/(1-L), where L is a Lipschitz constant for g.  
%   Examples: 
%          x = fixpoint1(@cos, 1, 1e-7) computes x=0.73908513
%   See also:
%          bisect.m
%
%----------------------------------------------------------------------

i=1;
x(i)=x0;
x(i+1)=g(x(i));

while abs(x(i+1)-x(i))>tol
  i=i+1;
  x(i+1)=g(x(i));
end

x=x';



