function demofp_2018(test)

if nargin < 1
test=1;
end

switch test
    case 1 % flat
        phi=inline('log(2-x)'); 
        % df=inline('exp(x)+1'); 
        x(1)=0;
        x(1)=1; 
        %x0=1;
        sol=0.4428544010023885;
    case 2
        f=inline('sin(x)'); 
        % df=inline('cos(x)-1'); 
        x(1)=-2; 
        % x(2)=3;
        sol=0;
end

tol=10^(-15);
kmax=10000;
% [x,ko]=newton2011(x0,tol,kmax,f,df);

[x, n, flag] = fpfun (phi, x(1), tol, kmax);

ae_old=NaN;

for ii=1:length(x)
    ae=abs(x(ii)-sol);
    if ii > 1
    steps=abs(x(ii)-x(ii-1));
    else
        steps=realmax;
    end
    if ii == 1
        fprintf('\n \t $%4.0f$ & $%1.15e$ & $%1.2e$ & $%1.2e$ ',...
    ii-1,x(ii),ae,steps);
    else
        fprintf('\n \t $%4.0f$ & $%1.15e$ & $%1.2e$ & $%1.2e$',...
    ii-1,x(ii),ae,steps);

    end
    ae_old=ae;
end

fprintf('\n \n');

figure(1)
ae=abs(x-sol);
semilogy(0:length(x)-1,ae,'r-','Linewidth',1);





