function errors_test16 ( )

%*****************************************************************************80
%
%% errors_test16()
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 August 2017
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '+=============================================+\n' );
  fprintf ( 1, '|                                             |\n' );
  fprintf ( 1, '|  Exercise 16                                |\n' );
  fprintf ( 1, '|                                             |\n' );
  fprintf ( 1, '|  P(X,Y) =                                   |\n' );
  fprintf ( 1, '|     83521 *       y^8                       |\n' );
  fprintf ( 1, '|    +  578 * x^2 * y^4                       |\n' );
  fprintf ( 1, '|    -    2 * x^4                             |\n' );
  fprintf ( 1, '|    +    2 * x^6                             |\n' );
  fprintf ( 1, '|    -        x^8                             |\n' );
  fprintf ( 1, '|                                             |\n' );
  fprintf ( 1, '|  Evaluate P(X,Y) for                        |\n' );
  fprintf ( 1, '|                                             |\n' );
  fprintf ( 1, '|    X = 9478657                              |\n' );
  fprintf ( 1, '|    Y = 2298912                              |\n' );
  fprintf ( 1, '|                                             |\n' );
  fprintf ( 1, '|  Correct value:                             |\n' );
  fprintf ( 1, '|                                             |\n' );
  fprintf ( 1, '|    P(X,Y) = - 179,689,877,047,297           |\n' );
  fprintf ( 1, '|                                             |\n' );
  fprintf ( 1, '+=============================================+\n' );
  fprintf ( 1, '\n' );

  x1 = 9478657.0;
  y1 = 2298912.0;

  z1 =    83521.0 *          y1 ^ 8 ...
        +   578.0 * x1 ^ 2 * y1 ^ 4 ...
        -     2.0 * x1 ^ 4          ...
        +     2.0 * x1 ^ 6          ...
        -           x1 ^ 8;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  P(X,Y) = %20.16g\n', z1 );

  scale = 1000000.0;
  x2 = x1 / scale;
  y2 = y1 / scale;

  z2 =    83521.0 *          y2 ^ 8 ...
        +   578.0 * x2 ^ 2 * y2 ^ 4 / scale ^ 2 ...
        -     2.0 * x2 ^ 4          / scale ^ 4 ...
        +     2.0 * x2 ^ 6          * scale ^ 2 ...
        -           x2 ^ 8;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Use a scale factor on X and Y of %g\n', scale );
  fprintf ( 1, '  Scaled value of P(X,Y) = %20.16g\n', z2 );
  fprintf ( 1, '  Computed value of P(X,Y) = %20.16g * %g ^ 8\n', z2, scale );

  return
end

