function p00_golden_section_test ( x_tol )

%*****************************************************************************80
%
%% p00_golden_section_test() tests p00_golden_section().
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    16 March 2026
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real x_tol: execution stops when the interval is smaller than x_tol.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'p00_golden_section_test():\n' );
  fprintf ( 1, '  Minimize using the golden section method.\n' );
  fprintf ( 1, '  Execution is halted when the interval is no more than %g\n', x_tol );
%
%  Get the number of tests.
%
  test_num = p00_test_num ( );

  for test = 1 : test_num

    title = p00_title ( test );

    fprintf ( 1, '\n' );
    fprintf ( 1, '  test %d\n', test );
    fprintf ( 1, '  "%s"\n', title );

    [ a, b ] = p00_interval ( test );
    n = 100;
 
    [ a, b, it, nf ] = golden_section ( @(x)p00_f ( test, x ), a, b, n, x_tol );
%
%  Print results.
%
    fa = p00_f ( test, a );
    fb = p00_f ( test, b );

    fprintf ( 1, '  Number of iterations: %d\n', it );
    fprintf ( 1, '  Function evaluations: %d\n', nf );
    fprintf ( 1, '  X:  %16.12e  %16.12e\n', a,   b );
    fprintf ( 1, '  F:  %16.12e  %16.12e\n', fa, fb );

  end

  return
end

