function goldstein_price_test ( )

%*****************************************************************************80
%
%% goldstein_price_test() works with the Goldstein-Price function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 January 2012
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'goldstein_price_test():\n' );
  fprintf ( 1, '  compass_search() applied to the Goldstein-Price function.\n' );
  m = 2;
  delta_tol = 0.00001;
  delta = 0.3;
  k_max = 20000;

  x = [ -0.5, 0.25 ];
  disp ( '  Initial point x0:' );
  disp ( x );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  F(X0) = %g\n', goldstein_price ( m, x ) );

  [ x, fx, k ] = compass_search ( @goldstein_price, m, x, delta_tol, delta, k_max );

  disp ( '  Estimated minimizer x1:' );
  disp ( x );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  F(X1) = %g, number of steps = %d\n', fx, k );
%
%  Repeat with more difficult start.
%
  x = [ -4.0, 5.0 ];
  disp ( '  Initial point x0:' );
  disp ( x );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  F(X0) = %g\n', goldstein_price ( m, x ) );

  [ x, fx, k ] = compass_search ( @goldstein_price, m, x, delta_tol, delta, k_max );

  disp ( '  Estimated minimizer x1:' );
  disp ( x );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  F(X1) = %g, number of steps = %d\n', fx, k );
%
%  Demonstrate correct minimizer.
%
  x = [ 0.0, -1.0 ];
  disp ( '  Correct minimizer x*:' );
  disp ( x );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  F(X*) = %g\n', goldstein_price ( m, x ) );

  return
end
