function test_example ( a, b, t, f, title )

%*****************************************************************************80
%
%% TEST_EXAMPLE tests LOCAL_MIN_RC on one test function.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    30 November 2016
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, real A, B, the endpoints of the interval.
%
%    Input, real T, a positive absolute error tolerance.
%
%    Input, real value = F ( x ), the name of a user-supplied
%    function whose local minimum is being sought.
%
%    Input, string TITLE, a title for the problem.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  %s\n', title );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Step      X                          F(X)\n' );
  fprintf ( 1, '\n' );
  step = 0;

  arg = a;
  value = f ( arg );
  fprintf ( 1, '  %4d  %24.16e  %24.16e\n', step, arg, value );

  arg = b;
  value = f ( arg );
  fprintf ( 1, '  %4d  %24.16e  %24.16e\n', step, arg, value );

  a2 = a;
  b2 = b;
  status = 0;

  while ( true )

    [ arg, status, a2, b2 ] = local_min_rc ( a2, b2, status, value );
 
    if ( status < 0 )
      fprintf ( 1, '\n' );
      fprintf ( 1, 'TEST_EXAMPLE - Fatal error!\n' );
      fprintf ( 1, '  LOCAL_MIN_RC returned negative status.\n' );
      break
    end

    value = f ( arg );

    step = step + 1;
    fprintf ( 1, '  %4d  %24.16e  %24.16e\n', step, arg, value );

    if ( status == 0 )
      break
    end

    if ( 50 < step )
      fprintf ( 1, '\n' );
      fprintf ( 1, 'TEST_EXAMPLE - Fatal error!\n' );
      fprintf ( 1, '  Too many steps.\n' );
      break
    end

  end

  return
end

