function [n,x,fx]=Secant(x,y)

  n=0; nmax=50; tol=1.0e-12; 

  if(abs(x-y)<tol)
    fprintf('Bad initial guesses, |x-y|< %.4e\n',tol);
    return;
  end
  
  fx=f(x);
  fy=f(y);

  if(abs(fx-fy) < tol)
    fprintf('Bad initial guesses, |fx-fy|< %.4e\n',tol);
    return;
  end

  while(n < nmax & abs(fx)>tol)
      z=x;
      x=x-(x-y)*fx/(fx-fy);
      y=z; fy=fx; fx=f(x);
      n=n+1;
  end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function y=f(x)
    
    y=(3*x-2)*(x*x+1);;