function errors_test18 ( )

%*****************************************************************************80
%
%% ERRORS_TEST18
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    22 August 2017
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '+=============================================+\n' );
  fprintf ( 1, '|                                             |\n' );
  fprintf ( 1, '|  Exercise 18                                |\n' );
  fprintf ( 1, '|                                             |\n' );
  fprintf ( 1, '|  X = 192119201                              |\n' );
  fprintf ( 1, '|  Y = 35675640                               |\n' );
  fprintf ( 1, '|                                             |\n' );
  fprintf ( 1, '|  Z(X,Y) =                                   |\n' );
  fprintf ( 1, '|    (                                        |\n' );
  fprintf ( 1, '|         1682 * x    * y^4                   |\n' );
  fprintf ( 1, '|       +    3 * x^3                          |\n' );
  fprintf ( 1, '|       +   29 * x    * y^2                   |\n' );
  fprintf ( 1, '|       -    2 * x^5                          |\n' );
  fprintf ( 1, '|       +  832                                |\n' );
  fprintf ( 1, '|      ) / 107751                             |\n' );
  fprintf ( 1, '|                                             |\n' );
  fprintf ( 1, '|  Correct Z:                                 |\n' );
  fprintf ( 1, '|                                             |\n' );
  fprintf ( 1, '|    1783.0                                   |\n' );
  fprintf ( 1, '|                                             |\n' );
  fprintf ( 1, '+=============================================+\n' );

  x1 = 192119201.0;
  y1 =  35675640.0;

  z1 = (      1682.0 * x1      * y1 ^ 4 ...
            +    3.0 * x1 ^ 3           ...
            +   29.0 * x1      * y1 ^ 2 ...
            -    2.0 * x1 ^ 5           ...
            +  832.0                    ...
          ) / 107751.0;

  fprintf ( 1,  '  Z = %20.16g\n', z1 );

  scale = 1000000.0;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  We use a scale factor on X and Y of %20.16g\n', scale );

  x2 = 192119201.0 / scale;
  y2 =  35675640.0 / scale;

  z2 = (      1682.0 * x2      * y2 ^ 4             ...
            +    3.0 * x2 ^ 3           / scale ^ 2 ...
            +   29.0 * x2      * y2 ^ 2 / scale ^ 2 ...
            -    2.0 * x2 ^ 5                       ...
            +  832.0                    / scale ^ 5 ...
          ) / 107751.0;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Scaled value of Z = %20.16g\n', z2 );
  fprintf ( 1, '  Computed value of Z = %20.16g * %20.16g ^ 5\n', z2, scale );

  return
end
