%
% File name: fixed_point.m  
%      Date: March 15, 2016  
%
clc  
clear all 
format long

%
% define the function    
%
g  = @(x) sqrt(10/(4+x));

p0           = 1.5;          % initial guess
maxiteration = 100;          % maximum number of iterations
tolerance    = 1e-12;        % stopping criterion 

iteration = 1;
[0, p0]
while iteration <= maxiteration
    
    p1 = g(p0);

    % check stopping criterion 
    if (abs(p0 - p1) < tolerance)
       [iteration, p1]
       break
    end
    [iteration, p1]
    
    % update  
    p0 = p1;
    iteration = iteration + 1;
end
iteration 