close all
clear all
clc
fname = 'func';
fpname='dfunc';disp(sprintf('k fval fpval '))

a = input('Enter parameter value:');
x0 = linspace(-10,10,201);
y0 = feval(fname,x0,a,b);
xc = input('Enter starting value:');
fc = feval(fname,xc,a,b);
%fpc=feval(fpname,xc,b);
%fpc=feval(fpname,xc,b);
delta = .0001;
fpc = (feval(fname,xc+delta,a,b)-fc)/delta;
k=0;
while input('secant step? (0=no, 1=yes)')
k=k+1;
x(k) = xc; y(k) = fc;
f_ = fc;
xnew = xc - fc/fpc;
x_ = xc;
xc = xnew;
fc = feval(fname,xc,a,b);
fpc= (fc - f_)/(xc-x_);
disp(sprintf('%2.0f %20.15f %20.15f %20.15f',k,xc,fc,fpc))
end
format long e
x(k) = xc
y(k) = fc
plot(x0,y0,x,y,'*')