function collatz_test07 ( )

%*****************************************************************************80
%
%% collatz_test07() plots the growth of the maximum Collatz count.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    16 June 2022
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Brian Hayes,
%    On the ups and downs of the hailstone numbers,
%    Scientific American,
%    January 1984.
%    
  fprintf ( 1, '\n' );
  fprintf ( 1, 'collatz_test07():\n' );
  fprintf ( 1, '  Plot the maximum Collatz count as n increases.\n' );

  n = [ ...
      1,     2,     3,     6,     7,     9,    18,    25,    27,    54, ...
     73,    97,   129,   171,   231,   313,   327,   649,   703,   871, ...
   1161,  2223,  2463,  2919,  3711,  6171, 10971, 13255, 17647, 23529, ...
  26623, 34239, 35655, 52527, 77031 ];

  c = [ ...
    0,   1,   7,   8,  16,  19,  20,  23, 111, 112, ...
  115, 118, 121, 124, 127, 130, 143, 144, 170, 178, ...
  181, 182, 208, 216, 237, 261, 267, 275, 278, 281, ...
  307, 310, 323, 339, 350 ];

  d = 30 * log ( n );

  clf ( );
  hold ( 'on' );
  semilogx ( n, c, 'r-', 'linewidth', 3 );
  semilogx ( n, d, 'g--', 'linewidth', 3 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( 'log(n)' );
  ylabel ( 'Maximum path length' );
  title ( 'Maximum path length as function of n' );
  legend ( 'MaxPath(n)', '30*log(n)', 'Location', 'south' );
  filename = 'collatz_count_max.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s".\n', filename );

  return
end
