qk15i.f

Go to the documentation of this file.
00001       subroutine qk15i(f,boun,inf,a,b,result,abserr,resabs,resasc,ierr)
00002 c***begin prologue  qk15i
00003 c***date written   800101   (yymmdd)
00004 c***revision date  830518   (yymmdd)
00005 c***category no.  h2a3a2,h2a4a2
00006 c***keywords  15-point transformed gauss-kronrod rules
00007 c***author  piessens,robert,appl. math. & progr. div. - k.u.leuven
00008 c           de doncker,elise,appl. math. & progr. div. - k.u.leuven
00009 c***purpose  the original (infinite integration range is mapped
00010 c            onto the interval (0,1) and (a,b) is a part of (0,1).
00011 c            it is the purpose to compute
00012 c            i = integral of transformed integrand over (a,b),
00013 c            j = integral of abs(transformed integrand) over (a,b).
00014 c***description
00015 c
00016 c           integration rule
00017 c           standard fortran subroutine
00018 c           real version
00019 c
00020 c           parameters
00021 c            on entry
00022 c              f      - subroutine f(x,ierr,result) defining the integrand
00023 c                       function f(x). the actual name for f needs to be
00024 c                       declared e x t e r n a l in the calling program.
00025 c
00026 c              boun   - real
00027 c                       finite bound of original integration
00028 c                       range (set to zero if inf = +2)
00029 c
00030 c              inf    - integer
00031 c                       if inf = -1, the original interval is
00032 c                                   (-infinity,bound),
00033 c                       if inf = +1, the original interval is
00034 c                                   (bound,+infinity),
00035 c                       if inf = +2, the original interval is
00036 c                                   (-infinity,+infinity) and
00037 c                       the integral is computed as the sum of two
00038 c                       integrals, one over (-infinity,0) and one over
00039 c                       (0,+infinity).
00040 c
00041 c              a      - real
00042 c                       lower limit for integration over subrange
00043 c                       of (0,1)
00044 c
00045 c              b      - real
00046 c                       upper limit for integration over subrange
00047 c                       of (0,1)
00048 c
00049 c            on return
00050 c              result - real
00051 c                       approximation to the integral i
00052 c                       result is computed by applying the 15-point
00053 c                       kronrod rule(resk) obtained by optimal addition
00054 c                       of abscissae to the 7-point gauss rule(resg).
00055 c
00056 c              abserr - real
00057 c                       estimate of the modulus of the absolute error,
00058 c                       which should equal or exceed abs(i-result)
00059 c
00060 c              resabs - real
00061 c                       approximation to the integral j
00062 c
00063 c              resasc - real
00064 c                       approximation to the integral of
00065 c                       abs((transformed integrand)-i/(b-a)) over (a,b)
00066 c
00067 c***references  (none)
00068 c***routines called  r1mach
00069 c***end prologue  qk15i
00070 c
00071       real a,absc,absc1,absc2,abserr,b,boun,centr,
00072      *  dinf,r1mach,epmach,fc,fsum,fval1,fval2,fvalt,fv1,
00073      *  fv2,hlgth,resabs,resasc,resg,resk,reskh,result,tabsc1,tabsc2,
00074      *  uflow,wg,wgk,xgk
00075       integer inf,j,min0
00076       external f
00077 c
00078       dimension fv1(7),fv2(7),xgk(8),wgk(8),wg(8)
00079 c
00080 c           the abscissae and weights are supplied for the interval
00081 c           (-1,1).  because of symmetry only the positive abscissae and
00082 c           their corresponding weights are given.
00083 c
00084 c           xgk    - abscissae of the 15-point kronrod rule
00085 c                    xgk(2), xgk(4), ... abscissae of the 7-point
00086 c                    gauss rule
00087 c                    xgk(1), xgk(3), ...  abscissae which are optimally
00088 c                    added to the 7-point gauss rule
00089 c
00090 c           wgk    - weights of the 15-point kronrod rule
00091 c
00092 c           wg     - weights of the 7-point gauss rule, corresponding
00093 c                    to the abscissae xgk(2), xgk(4), ...
00094 c                    wg(1), wg(3), ... are set to zero.
00095 c
00096       data xgk(1),xgk(2),xgk(3),xgk(4),xgk(5),xgk(6),xgk(7),
00097      *  xgk(8)/
00098      *     0.9914553711208126e+00,     0.9491079123427585e+00,
00099      *     0.8648644233597691e+00,     0.7415311855993944e+00,
00100      *     0.5860872354676911e+00,     0.4058451513773972e+00,
00101      *     0.2077849550078985e+00,     0.0000000000000000e+00/
00102 c
00103       data wgk(1),wgk(2),wgk(3),wgk(4),wgk(5),wgk(6),wgk(7),
00104      *  wgk(8)/
00105      *     0.2293532201052922e-01,     0.6309209262997855e-01,
00106      *     0.1047900103222502e+00,     0.1406532597155259e+00,
00107      *     0.1690047266392679e+00,     0.1903505780647854e+00,
00108      *     0.2044329400752989e+00,     0.2094821410847278e+00/
00109 c
00110       data wg(1),wg(2),wg(3),wg(4),wg(5),wg(6),wg(7),wg(8)/
00111      *     0.0000000000000000e+00,     0.1294849661688697e+00,
00112      *     0.0000000000000000e+00,     0.2797053914892767e+00,
00113      *     0.0000000000000000e+00,     0.3818300505051189e+00,
00114      *     0.0000000000000000e+00,     0.4179591836734694e+00/
00115 c
00116 c
00117 c           list of major variables
00118 c           -----------------------
00119 c
00120 c           centr  - mid point of the interval
00121 c           hlgth  - half-length of the interval
00122 c           absc*  - abscissa
00123 c           tabsc* - transformed abscissa
00124 c           fval*  - function value
00125 c           resg   - result of the 7-point gauss formula
00126 c           resk   - result of the 15-point kronrod formula
00127 c           reskh  - approximation to the mean value of the transformed
00128 c                    integrand over (a,b), i.e. to i/(b-a)
00129 c
00130 c           machine dependent constants
00131 c           ---------------------------
00132 c
00133 c           epmach is the largest relative spacing.
00134 c           uflow is the smallest positive magnitude.
00135 c
00136 c***first executable statement  qk15i
00137       epmach = r1mach(4)
00138       uflow = r1mach(1)
00139       dinf = min0(1,inf)
00140 c
00141       centr = 0.5e+00*(a+b)
00142       hlgth = 0.5e+00*(b-a)
00143       tabsc1 = boun+dinf*(0.1e+01-centr)/centr
00144       call f(tabsc1, ierr, fval1)
00145       if (ierr.lt.0) return
00146       if(inf.eq.2) then
00147          call f(-tabsc1, ierr, fval1)
00148          if (ierr.lt.0) return
00149          fval1 = fval1 + fvalt
00150       endif
00151       fc = (fval1/centr)/centr
00152 c
00153 c           compute the 15-point kronrod approximation to
00154 c           the integral, and estimate the error.
00155 c
00156       resg = wg(8)*fc
00157       resk = wgk(8)*fc
00158       resabs = abs(resk)
00159       do 10 j=1,7
00160         absc = hlgth*xgk(j)
00161         absc1 = centr-absc
00162         absc2 = centr+absc
00163         tabsc1 = boun+dinf*(0.1e+01-absc1)/absc1
00164         tabsc2 = boun+dinf*(0.1e+01-absc2)/absc2
00165         call f(tabsc1, ierr, fval1)
00166         if (ierr.lt.0) return
00167         call f(tabsc2, ierr, fval2)
00168         if (ierr.lt.0) return
00169         if(inf.eq.2) then
00170            call f(-tabsc1,ierr,fvalt)
00171            if (ierr.lt.0) return
00172            fval1 = fval1 + fvalt
00173         endif
00174         if(inf.eq.2) then
00175            call f(-tabsc2,ierr,fvalt)
00176            if (ierr.lt.0) return
00177            fval2 = fval2 + fvalt
00178         endif
00179         fval1 = (fval1/absc1)/absc1
00180         fval2 = (fval2/absc2)/absc2
00181         fv1(j) = fval1
00182         fv2(j) = fval2
00183         fsum = fval1+fval2
00184         resg = resg+wg(j)*fsum
00185         resk = resk+wgk(j)*fsum
00186         resabs = resabs+wgk(j)*(abs(fval1)+abs(fval2))
00187    10 continue
00188       reskh = resk*0.5e+00
00189       resasc = wgk(8)*abs(fc-reskh)
00190       do 20 j=1,7
00191         resasc = resasc+wgk(j)*(abs(fv1(j)-reskh)+abs(fv2(j)-reskh))
00192    20 continue
00193       result = resk*hlgth
00194       resasc = resasc*hlgth
00195       resabs = resabs*hlgth
00196       abserr = abs((resk-resg)*hlgth)
00197       if(resasc.ne.0.0e+00.and.abserr.ne.0.e0) abserr = resasc*
00198      * amin1(0.1e+01,(0.2e+03*abserr/resasc)**1.5e+00)
00199       if(resabs.gt.uflow/(0.5e+02*epmach)) abserr = amax1
00200      * ((epmach*0.5e+02)*resabs,abserr)
00201       return
00202       end
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines