qng Subroutine

public subroutine qng(f, a, b, epsabs, epsrel, result, abserr, neval, ier)

QNG estimates an integral, using non-adaptive integration.

Discussion:

The routine calculates an approximation RESULT to a definite integral
I = integral of F over (A,B), hopefully satisfying || I - RESULT || <= max ( EPSABS, EPSREL * ||I|| ).

The routine is a simple non-adaptive automatic integrator, based on a sequence of rules with increasing degree of algebraic precision (Patterson, 1968).

Author:

Robert Piessens, Elise de Doncker-Kapenger, Christian Ueberhuber, David Kahaner

Reference:

Robert Piessens, Elise de Doncker-Kapenger, Christian Ueberhuber, David Kahaner, QUADPACK, a Subroutine Package for Automatic Integration, Springer Verlag, 1983

Parameters:

Input, external real F, the name of the function routine, of the form function f ( x ) real f real x which evaluates the integrand function.

Input, real A, B, the limits of integration.

Input, real EPSABS, EPSREL, the absolute and relative accuracy requested.

Output, real RESULT, the estimated value of the integral. RESULT is obtained by applying the 21-point Gauss-Kronrod rule (RES21) obtained by optimal addition of abscissae to the 10-point Gauss rule (RES10), or by applying the 43-point rule (RES43) obtained by optimal addition of abscissae to the 21-point Gauss-Kronrod rule, or by applying the 87-point rule (RES87) obtained by optimal addition of abscissae to the 43-point rule.

Output, real ABSERR, an estimate of || I - RESULT ||.

Output, integer NEVAL, the number of times the integral was evaluated.

      ier    - ier = 0 normal and reliable termination of the
                       routine. it is assumed that the requested
                       accuracy has been achieved.
               ier > 0 abnormal termination of the routine. it is
                       assumed that the requested accuracy has
                       not been achieved.
               ier = 1 the maximum number of steps has been
                       executed. the integral is probably too
                       difficult to be calculated by qng.
                   = 6 the input is invalid, because
                       epsabs < 0 and epsrel < 0,
                       result, abserr and neval are set to zero.

Local Parameters:

      centr  - mid point of the integration interval
      hlgth  - half-length of the integration interval
      fcentr - function value at mid point
      absc   - abscissa
      fval   - function value
      savfun - array of function values which have already
               been computed
      res10  - 10-point Gauss result
      res21  - 21-point Kronrod result
      res43  - 43-point result
      res87  - 87-point result
      resabs - approximation to the integral of abs(f)
      resasc - approximation to the integral of abs(f-i/(b-a))

Arguments

Type IntentOptional Attributes Name
procedure(scalar_func) :: f
real :: a
real :: b
real :: epsabs
real :: epsrel
real :: result
real :: abserr
integer :: neval
integer :: ier

Contents