qagi.f

Go to the documentation of this file.
00001       subroutine qagi(f,bound,inf,epsabs,epsrel,result,abserr,neval,
00002      *   ier,limit,lenw,last,iwork,work)
00003 c***begin prologue  qagi
00004 c***date written   800101   (yymmdd)
00005 c***revision date  830518   (yymmdd)
00006 c***category no.  h2a3a1,h2a4a1
00007 c***keywords  automatic integrator, infinite intervals,
00008 c             general-purpose, transformation, extrapolation,
00009 c             globally adaptive
00010 c***author  piessens,robert,appl. math. & progr. div. - k.u.leuven
00011 c           de doncker,elise,appl. math. & progr. div. -k.u.leuven
00012 c***purpose  the routine calculates an approximation result to a given
00013 c            integral   i = integral of f over (bound,+infinity)
00014 c                    or i = integral of f over (-infinity,bound)
00015 c                    or i = integral of f over (-infinity,+infinity)
00016 c            hopefully satisfying following claim for accuracy
00017 c            abs(i-result).le.max(epsabs,epsrel*abs(i)).
00018 c***description
00019 c
00020 c        integration over infinite intervals
00021 c        standard fortran subroutine
00022 c
00023 c        parameters
00024 c         on entry
00025 c            f      - subroutine f(x,result) defining the integrand
00026 c                     function f(x). the actual name for f needs to be
00027 c                     declared e x t e r n a l in the driver program.
00028 c
00029 c            bound  - real
00030 c                     finite bound of integration range
00031 c                     (has no meaning if interval is doubly-infinite)
00032 c
00033 c            inf    - integer
00034 c                     indicating the kind of integration range involved
00035 c                     inf = 1 corresponds to  (bound,+infinity),
00036 c                     inf = -1            to  (-infinity,bound),
00037 c                     inf = 2             to (-infinity,+infinity).
00038 c
00039 c            epsabs - real
00040 c                     absolute accuracy requested
00041 c            epsrel - real
00042 c                     relative accuracy requested
00043 c                     if  epsabs.le.0
00044 c                     and epsrel.lt.max(50*rel.mach.acc.,0.5d-28),
00045 c                     the routine will end with ier = 6.
00046 c
00047 c
00048 c         on return
00049 c            result - real
00050 c                     approximation to the integral
00051 c
00052 c            abserr - real
00053 c                     estimate of the modulus of the absolute error,
00054 c                     which should equal or exceed abs(i-result)
00055 c
00056 c            neval  - integer
00057 c                     number of integrand evaluations
00058 c
00059 c            ier    - integer
00060 c                     ier = 0 normal and reliable termination of the
00061 c                             routine. it is assumed that the requested
00062 c                             accuracy has been achieved.
00063 c                   - ier.gt.0 abnormal termination of the routine. the
00064 c                             estimates for result and error are less
00065 c                             reliable. it is assumed that the requested
00066 c                             accuracy has not been achieved.
00067 c            error messages
00068 c                     ier = 1 maximum number of subdivisions allowed
00069 c                             has been achieved. one can allow more
00070 c                             subdivisions by increasing the value of
00071 c                             limit (and taking the according dimension
00072 c                             adjustments into account). however, if
00073 c                             this yields no improvement it is advised
00074 c                             to analyze the integrand in order to
00075 c                             determine the integration difficulties. if
00076 c                             the position of a local difficulty can be
00077 c                             determined (e.g. singularity,
00078 c                             discontinuity within the interval) one
00079 c                             will probably gain from splitting up the
00080 c                             interval at this point and calling the
00081 c                             integrator on the subranges. if possible,
00082 c                             an appropriate special-purpose integrator
00083 c                             should be used, which is designed for
00084 c                             handling the type of difficulty involved.
00085 c                         = 2 the occurrence of roundoff error is
00086 c                             detected, which prevents the requested
00087 c                             tolerance from being achieved.
00088 c                             the error may be under-estimated.
00089 c                         = 3 extremely bad integrand behaviour occurs
00090 c                             at some points of the integration
00091 c                             interval.
00092 c                         = 4 the algorithm does not converge.
00093 c                             roundoff error is detected in the
00094 c                             extrapolation table.
00095 c                             it is assumed that the requested tolerance
00096 c                             cannot be achieved, and that the returned
00097 c                             result is the best which can be obtained.
00098 c                         = 5 the integral is probably divergent, or
00099 c                             slowly convergent. it must be noted that
00100 c                             divergence can occur with any other value
00101 c                             of ier.
00102 c                         = 6 the input is invalid, because
00103 c                             (epsabs.le.0 and
00104 c                              epsrel.lt.max(50*rel.mach.acc.,0.5d-28))
00105 c                              or limit.lt.1 or leniw.lt.limit*4.
00106 c                             result, abserr, neval, last are set to
00107 c                             zero. exept when limit or leniw is
00108 c                             invalid, iwork(1), work(limit*2+1) and
00109 c                             work(limit*3+1) are set to zero, work(1)
00110 c                             is set to a and work(limit+1) to b.
00111 c
00112 c         dimensioning parameters
00113 c            limit - integer
00114 c                    dimensioning parameter for iwork
00115 c                    limit determines the maximum number of subintervals
00116 c                    in the partition of the given integration interval
00117 c                    (a,b), limit.ge.1.
00118 c                    if limit.lt.1, the routine will end with ier = 6.
00119 c
00120 c            lenw  - integer
00121 c                    dimensioning parameter for work
00122 c                    lenw must be at least limit*4.
00123 c                    if lenw.lt.limit*4, the routine will end
00124 c                    with ier = 6.
00125 c
00126 c            last  - integer
00127 c                    on return, last equals the number of subintervals
00128 c                    produced in the subdivision process, which
00129 c                    determines the number of significant elements
00130 c                    actually in the work arrays.
00131 c
00132 c         work arrays
00133 c            iwork - integer
00134 c                    vector of dimension at least limit, the first
00135 c                    k elements of which contain pointers
00136 c                    to the error estimates over the subintervals,
00137 c                    such that work(limit*3+iwork(1)),... ,
00138 c                    work(limit*3+iwork(k)) form a decreasing
00139 c                    sequence, with k = last if last.le.(limit/2+2), and
00140 c                    k = limit+1-last otherwise
00141 c
00142 c            work  - real
00143 c                    vector of dimension at least lenw
00144 c                    on return
00145 c                    work(1), ..., work(last) contain the left
00146 c                     end points of the subintervals in the
00147 c                     partition of (a,b),
00148 c                    work(limit+1), ..., work(limit+last) contain
00149 c                     the right end points,
00150 c                    work(limit*2+1), ...,work(limit*2+last) contain the
00151 c                     integral approximations over the subintervals,
00152 c                    work(limit*3+1), ..., work(limit*3)
00153 c                     contain the error estimates.
00154 c***references  (none)
00155 c***routines called  qagie,xerror
00156 c***end prologue  qagi
00157 c
00158       real   abserr,  epsabs,epsrel,result,work
00159       integer ier,iwork,    lenw,limit,lvl,l1,l2,l3,neval
00160 c
00161       dimension iwork(limit),work(lenw)
00162 c
00163       external f
00164 c
00165 c         check validity of limit and lenw.
00166 c
00167 c***first executable statement  qagi
00168       ier = 6
00169       neval = 0
00170       last = 0
00171       result = 0.0e+00
00172       abserr = 0.0e+00
00173       if(limit.lt.1.or.lenw.lt.limit*4) go to 10
00174 c
00175 c         prepare call for qagie.
00176 c
00177       l1 = limit+1
00178       l2 = limit+l1
00179       l3 = limit+l2
00180 c
00181       call qagie(f,bound,inf,epsabs,epsrel,limit,result,abserr,
00182      *  neval,ier,work(1),work(l1),work(l2),work(l3),iwork,last)
00183 c
00184 c         call error handler if necessary.
00185 c
00186       lvl = 0
00187 10    if(ier.eq.6) lvl = 1
00188       if(ier.ne.0) call xerror('abnormal return from  qagi',26,ier,lvl)
00189       return
00190       end
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines