function mrgfls_test ( )

%*****************************************************************************80
%
%% mrgfls_test tests mrgfls().
%
%  Reference:
%
%    Samuel Conte, Carl de Boor,
%    Elementary Numerical Analysis,
%    Third Edition,
%    SIAM, 2017,
%    ISBN: 978-1-611975-19-2.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'mrgfls_test\n' );
  fprintf ( 1, '  Test mrgfls()\n' );

  for j=1:4
   switch j
   case 1, [W,A,B,IFLAG] = mrgfls(@F,  2, 3, 1.e-9,1.e-7,10);
   case 2, [W,A,B,IFLAG] = mrgfls(@F, 1, 2, 1.e-1,1.e-7,10);
   case 3, [W,A,B,IFLAG] = mrgfls(@F, 1, 2, 1.e-9,1.e-7,10);
   case 4, [W,A,B,IFLAG] = mrgfls(@F, 1, 2, 1.e-9,1.e-9,4);
   end
   
   fprintf(' The zero is %e  within [%e .. %e], IFLAG = %d\n', ...
              [W,A,B,IFLAG])
  end

  return
end
function fx = F(X)
fx = -1 - X*(1-X*X);
fprintf('  X = %e,  F(X) = %e\n', [X, fx])
end
