qags Subroutine

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

QAGS estimates the integral of a function.

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|| ).

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.

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

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

Output, integer IER, error flag. 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 the estimates for integral and error are less reliable. it is assumed that the requested accuracy has not been achieved. = 1 maximum number of subdivisions allowed has been achieved. one can allow more sub- divisions by increasing the data value of limit in qags (and taking the according dimension adjustments into account). however, if this yields no improvement it is advised to analyze the integrand in order to determine the integration difficulties. if the position of a local difficulty can be determined (e.g. singularity, discontinuity within the interval) one will probably gain from splitting up the interval at this point and calling the integrator on the sub- ranges. if possible, an appropriate special-purpose integrator should be used, which is designed for handling the type of difficulty involved. = 2 the occurrence of roundoff error is detec- ted, which prevents the requested tolerance from being achieved. the error may be under-estimated. = 3 extremely bad integrand behavior occurs at some points of the integration interval. = 4 the algorithm does not converge. roundoff error is detected in the extrapolation table. it is presumed that the requested tolerance cannot be achieved, and that the returned result is the best which can be obtained. = 5 the integral is probably divergent, or slowly convergent. it must be noted that divergence can occur with any other value of ier. = 6 the input is invalid, because epsabs < 0 and epsrel < 0, result, abserr and neval are set to zero.

Local Parameters:

      alist     - list of left end points of all subintervals
                  considered up to now
      blist     - list of right end points of all subintervals
                  considered up to now
      rlist(i)  - approximation to the integral over
                  (alist(i),blist(i))
      rlist2    - array of dimension at least limexp+2 containing
                  the part of the epsilon table which is still
                  needed for further computations
      elist(i)  - error estimate applying to rlist(i)
      maxerr    - pointer to the interval with largest error
                  estimate
      errmax    - elist(maxerr)
      erlast    - error on the interval currently subdivided
                  (before that subdivision has taken place)
      area      - sum of the integrals over the subintervals
      errsum    - sum of the errors over the subintervals
      errbnd    - requested accuracy max(epsabs,epsrel*
                  abs(result))
      *****1    - variable for the left interval
      *****2    - variable for the right interval
      last      - index for subdivision
      nres      - number of calls to the extrapolation routine
      numrl2    - number of elements currently in rlist2. if an
                  appropriate approximation to the compounded
                  integral has been obtained it is put in
                  rlist2(numrl2) after numrl2 has been increased
                  by one.
      small     - length of the smallest interval considered
                  up to now, multiplied by 1.5
      erlarg    - sum of the errors over the intervals larger
                  than the smallest interval considered up to now
      extrap    - logical variable denoting that the routine is
                  attempting to perform extrapolation i.e. before
                  subdividing the smallest interval we try to
                  decrease the value of erlarg.
      noext     - logical variable denoting that extrapolation
                  is no longer allowed (true value)

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