function range_by_fmincon_test ( )

%*****************************************************************************80
%
%% range_by_fmincon() uses fmincon() to estimate the range.
%
%  Discussion:
%
%    fmincon is much more powerful than sampling in finding the range.
%
%    I just started this test, and only call the butcher function now.
%
%    Dealing with fmincon's quirks is a little tedious.  To maximize, you
%    need the negative of the function, and I just found it easier to make
%    two versions of the function, and then name them carefully, rather than
%    trying to "do the right thing" and have a single function which somehow
%    knows whether it should be negated or not.
%
%    You'd think fmincon would just have an input option to maximize...
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    27 February 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'range_by_fmincon_test():\n' );
  fprintf ( 1, '  Use the MATLAB fmincon() function to seek range.\n' );

  options = optimoptions ( 'fmincon', 'Display', 'off' );
%
%  Butcher.
%
  m = butcher_m ( );
  [ lb, ub ] = butcher_b ( m );
  x0 = ( lb + ub ) / 2.0;
  [ x_min, f_min ] = fmincon ( @butcher_min_fun, x0, [], [], [], [], lb, ub, [], options );
  [ x_max, f_max ] = fmincon ( @butcher_max_fun, x0, [], [], [], [], lb, ub, [], options );
  f_max = - f_max;
  g_min = -1.4393333333;
  g_max = +0.219;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  butcher known:     [%20.10g %20.10g]\n', g_min, g_max );
  fprintf ( 1, '  Butcher estimated: [%20.10g %20.10g]\n', f_min, f_max );

  return
end

