function polynomial2_test ( )

%*****************************************************************************80
%
%% polynomial2_test() deals with a random polynomial.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 December 2023
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'polynomial2_test():\n' );
  fprintf ( 1, '  Bound the roots of a random polynomial:\n' );

  n = 5;

  r = randn ( n, 1 ) + randn ( n, 1 ) * i;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Polynomial roots are:\n' );
  disp ( r );

  c = poly ( r );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Polynomial coefficients are:\n' );
  disp ( c );

  b = polynomial_root_bound ( c );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Root magnitude bound is %g\n', b );

  clf ( );
  hold ( 'on' );
    plot ( real ( r ), imag ( r ), 'b.', 'markersize', 20 );
    t = linspace ( 0.0, 2.0 * pi, 49 );
    cx = b * cos ( t );
    cy = b * sin ( t );
    plot ( cx, cy, 'r', 'linewidth', 3 );
  hold ( 'off' );
  grid ( 'on' );
  axis ( 'equal' );
  title ( 'Polynomial #2' );
  filename = 'polynomial2_test.png';
  print ( '-dpng', filename );  
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

