%secant method iterant
close all
clear all
clc
%demfun1=inline('(1/x)-c')
c = 7;  %test case
xk = input('enter first guess point: ')
xk=0.1; %guess point
xkp1 = input('enter second guess point: ')
fxk = demfun1(xk);
%xkp1 = 0.2  %second guess point
tol = 1.E-10;
%in loop, xk is previous, xkm1 is previous to xk
% xkp1 is next value of x
while (abs(xkp1-xk)>tol)
   xkm1=xk;
   fxkm1=fxk;
   xk=xkp1;
   fxk=demfun1(xk);
   xkp1=xk-fxk*(xk-xkm1)/(fxk-fxkm1);
   fprintf('\nxkp1= %14.10f xk = %14.10f',xkp1,xk)
end