function beale_test ( )

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

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

  [ x, fx, k ] = compass_search ( @beale, 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 = [ 1.0, 4.0 ];
  disp ( '  Initial point x0:' );
  disp ( x );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  F(X0) = %g\n', beale ( m, x ) );

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

  return
end
