function fixedpoint

xp = 0;
xc = 0.2;
tol = 10^(-8);
Nmax = 200;

for j=1:Nmax
    
    xp = xc;
    xc = g(xc);
    if abs(xc-xp) < tol
        break;
    end
    Error = (-1+sqrt(5))/2-xc
end
xc
iterations = j

function y = g(x)

%y = 1-x^2;
%y = sqrt(1-x);
y = (x^2+1)/(2*x+1);