function secant(x,y,Niter,tol)

disp("")
disp ("Output for the Secant method")
disp("")
disp ("           n           x         err        f(x)")  

for i=1:Niter
  if (f(x)==0 |abs(x-y)<tol)
    disp("")
    disp ("The method completed successfully!")
    disp("")
    return;
  else
    epsilon=abs(f(y)*(y-x)/(f(y)-f(x)));
    disp ([i-1,x, epsilon, f(x)]);
    oldx=y;
    y=y-f(y)*(y-x)/(f(y)-f(x));
    x=oldx;
  endif 
endfor
disp("")
disp ("The method failed after (Niter)")
disp (Niter)
disp ("iterations")
disp("")
endfunction