function local_min_rc_example ( a, b, f, title )

%*****************************************************************************80
%
%% local_min_rc_example() tests local_min_rc() on one test function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 May 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real A, B, the endpoints of the interval.
%
%    real value = F ( x ), the name of a user-supplied
%    function whose local minimum is being sought.
%
%    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, 'local_min_rc_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, 'local_min_rc_example(): Fatal error!\n' );
      fprintf ( 1, '  Too many steps.\n' );
      break
    end

  end

  return
end

