function [x1,err,k,y]=secant(f,x0,x1,delta,epsilon,max1)
for k=1:max1
    x2=x1-feval(f,x1)*(x1-x0)/(feval(f,x1)-feval(f,x0));
    err=abs(x2-x1);
    relerr=2*err/(abs(x2)+delta);
    x0=x1;
    x1=x2;
    y=feval(f,x1);
    if (err<delta)|(relerr<delta)|(abs(y)<epsilon),break,end
end