function himmelblau_test ( )

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

  x = [ 1.0, 1.0 ];
  disp ( '  Initial point x0:' );
  disp ( x );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  F(X0) = %g\n', himmelblau ( m, x ) );

  [ x, fx, k ] = compass_search ( @himmelblau, 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 );

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

  [ x, fx, k ] = compass_search ( @himmelblau, 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 );

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

  [ x, fx, k ] = compass_search ( @himmelblau, 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 );

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

  [ x, fx, k ] = compass_search ( @himmelblau, 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 Himmelblau minimizers.
%
  x = [ 3.0, 2.0 ];
  disp ( '  Correct minimizer x1*:' );
  disp ( x );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  F(X*) = %g\n', himmelblau ( m, x ) );

  x = [ 3.58439, -1.84813 ];
  disp ( '  Correct minimizer x2*:' );
  disp ( x );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  F(X*) = %g\n', himmelblau ( m, x ) );

  x = [ -3.77934, -3.28317 ];
  disp ( '  Correct minimizer x3*:' );
  disp ( x );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  F(X*) = %g\n', himmelblau ( m, x ) );

  x = [ -2.80512,  3.13134 ];
  disp ( '  Correct minimizer x4*:' );
  disp ( x );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  F(X*) = %g\n', himmelblau ( m, x ) );

  return
end
