function broyden_test02 ( )

%*****************************************************************************80
%
%% broyden_test02() tests broyden() on 2 nonlinear equations.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 April 2021
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'broyden_test02():\n' );
  fprintf ( 1, '  broyden() solves a system of nonlinear equations\n' );
  fprintf ( 1, '  using Broyden''s method.\n' );
  fprintf ( 1, '  Test it on 2 nonlinear equations.\n' );

  n = 2;
  x = [ 4.0; 0.0 ];
  fx = f2 ( x );
  fprintf ( 1, '  Initial residual norm: %f\n', norm ( fx ) );
 
  atol = 0.000001;
  rtol = 0.000001;

  maxit = 10;
  maxdim = 2;

  [ x, ierr ] = broyden ( x, @f2, atol, rtol, maxit, maxdim );

  fx = f2 ( x );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Final residual norm: %f\n', norm ( fx ) );

  return
end
