function simpson_error ( )

%*****************************************************************************80
%
%% SIMPSON_ERROR observes quadrature error for Simpson's rule with increasing N.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    25 February 2013
%
%  Author:
%
%    John Burkardt
%
  n = 1;
  a = 0.0;
  b = 10.0;
  exact = exp ( b ) - exp ( a );

  fprintf ( 1, '\n' );
  fprintf ( 1, '       N          Q              E                Eold/E\n' );
  fprintf ( 1, '\n' );

  for nlog = 0 : 10
    q = 0.0;
    dx = ( b - a ) / n;
    for i = 1 : n

      w = ( 1.0 / 6.0 ) * ( b - a ) / n;
      x = a + ( i - 1 ) * dx;
      q = q + w * exp ( x );

      w = ( 4.0 / 6.0 ) * ( b - a ) / n;
      x = x + 0.5 * dx;
      q = q + w * exp ( x );

      w = ( 1.0 / 6.0 ) * ( b - a ) / n;
      x = x + 0.5 * dx;
      q = q + w * exp ( x );

    end

    if ( 0 < nlog )
      e_old = e;
    end
    e = abs ( exact - q );
    if ( 0 == nlog )
      fprintf ( 1, '  %6d  %14.6g  %14.6g\n', n, q, e );
    else
      fprintf ( 1, '  %6d  %14.6g  %14.6g  %14.6g\n', n, q, e, e_old / e );
    end

    n = 2 * n;

  end

  return
end

