function broyden_test ( )

%*****************************************************************************80
%
%% broyden_test() tests broyden() on the Chandrasekhar function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 April 2021
%
%  Author:
%
%    John Burkardt
%
  n = 100;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'broyden_test():\n' );
  fprintf ( 1, '  broyden() solves a system of nonlinear equations\n' );
  fprintf ( 1, '  using Broyden''s method.\n' );
  fprintf ( 1, '  Test it on the Chandrasekhar function.\n' );
%
%  Initial estimate.
%
  h(1:n,1) = 1.0;

  tol(1) = 0.000001;
  tol(2) = 0.000001;

  maxit = 10;
  maxdim = 2;
  linprob = false;

  parms = [ maxit, maxdim, linprob ];

  [ sol, it_hist, ierr ] = broyden ( h, @chandrasekhar, tol, parms );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Error flag IERR = %d\n', ierr );

  f = chandrasekhar ( sol );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Residual norm: %f\n', norm ( f ) );

  it_hist

  return
end
