## Function Integrate-Qag

### Part of:

package lisplab
( integrate-qag < f > < a > < b > &key (key 0) (limit 100) (epsabs 0.0d0) (epsrel 1.d-5) )
Compute the integral of f(x) from a to b.

b
/
[
I f(x) dx
]
/
a

f - double precision
function subprogam defining the integrand
function f(x). the actual name for f needs to be

a - double precision
lower limit of integration

b - double precision
upper limit of integration

epsabs - double precision
absolute accoracy requested
epsrel - double precision
relative accuracy requested
if epsabs.le.0
and epsrel.lt.max(50*rel.mach.acc.,0.5d-28),
the routine will end with ier = 6.

key - integer
key for choice of local integration rule
a gauss-kronrod pair is used with
7 - 15 points if key.lt.2,
10 - 21 points if key = 2,
15 - 31 points if key = 3,
20 - 41 points if key = 4,
25 - 51 points if key = 5,
30 - 61 points if key.gt.5.

limit - limit determines the maximum number of subintervals
in the partition of the given integration interval
(a,b), limit.ge.1.
if limit.lt.1, the routine will end with ier = 6.

RETURN
result - approximation to the integral

ier - ier = 0 normal and reliable termination of the
routine. it is assumed that the requested
accuracy has been achieved.
ier.gt.0 abnormal termination of the routine
the estimates for result and error are
less reliable. it is assumed that the
requested accuracy has not been achieved.
abserr - estimate of the modulus of the absolute error,
which should equal or exceed abs(i-result)

neval - number of integrand evaluations

last - on return, last equals the number of
subintervals produced in the subdivision process,
which determines the significant number of
elements actually in the work arrays.

ERROR MESSAGES
ier = 1 maximum number of subdivisions allowed
has been achieved. one can allow more
subdivisions by increasing the value of
limit (and taking the according dimension
this yield no improvement it is advised
to analyze the integrand in order to
determine the integration difficulaties.
if the position of a local difficulty can
be determined (i.e.singularity,
discontinuity within the interval) one
will probably gain from splitting up the
interval at this point and calling the
integrator on the subranges. 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
detected, which prevents the requested
tolerance from being achieved.
= 3 extremely bad integrand behaviour occurs
at some points of the integration
interval.
= 6 the input is invalid, because
(epsabs.le.0 and
epsrel.lt.max(50*rel.mach.acc.,0.5d-28))
or limit.lt.1 or lenw.lt.limit*4.
result, abserr, neval, last are set
to zero.
except when lenw is invalid, iwork(1),
work(limit*2+1) and work(limit*3+1) are
set to zero, work(1) is set to a and
work(limit+1) to b.