qelg.f

Go to the documentation of this file.
00001       subroutine qelg(n,epstab,result,abserr,res3la,nres)
00002 c***begin prologue  qelg
00003 c***refer to  qagie,qagoe,qagpe,qagse
00004 c***routines called  r1mach
00005 c***revision date  830518   (yymmdd)
00006 c***keywords  epsilon algorithm, convergence acceleration,
00007 c             extrapolation
00008 c***author  piessens,robert,appl. math. & progr. div. - k.u.leuven
00009 c           de doncker,elise,appl. math & progr. div. - k.u.leuven
00010 c***purpose  the routine determines the limit of a given sequence of
00011 c            approximations, by means of the epsilon algorithm of
00012 c            p. wynn. an estimate of the absolute error is also given.
00013 c            the condensed epsilon table is computed. only those
00014 c            elements needed for the computation of the next diagonal
00015 c            are preserved.
00016 c***description
00017 c
00018 c           epsilon algorithm
00019 c           standard fortran subroutine
00020 c           real version
00021 c
00022 c           parameters
00023 c              n      - integer
00024 c                       epstab(n) contains the new element in the
00025 c                       first column of the epsilon table.
00026 c
00027 c              epstab - real
00028 c                       vector of dimension 52 containing the elements
00029 c                       of the two lower diagonals of the triangular
00030 c                       epsilon table. the elements are numbered
00031 c                       starting at the right-hand corner of the
00032 c                       triangle.
00033 c
00034 c              result - real
00035 c                       resulting approximation to the integral
00036 c
00037 c              abserr - real
00038 c                       estimate of the absolute error computed from
00039 c                       result and the 3 previous results
00040 c
00041 c              res3la - real
00042 c                       vector of dimension 3 containing the last 3
00043 c                       results
00044 c
00045 c              nres   - integer
00046 c                       number of calls to the routine
00047 c                       (should be zero at first call)
00048 c
00049 c***end prologue  qelg
00050 c
00051       real abserr,delta1,delta2,delta3,r1mach,
00052      *  epmach,epsinf,epstab,error,err1,err2,err3,e0,e1,e1abs,e2,e3,
00053      *  oflow,res,result,res3la,ss,tol1,tol2,tol3
00054       integer i,ib,ib2,ie,indx,k1,k2,k3,limexp,n,newelm,nres,num
00055       dimension epstab(52),res3la(3)
00056 c
00057 c           list of major variables
00058 c           -----------------------
00059 c
00060 c           e0     - the 4 elements on which the
00061 c           e1       computation of a new element in
00062 c           e2       the epsilon table is based
00063 c           e3                 e0
00064 c                        e3    e1    new
00065 c                              e2
00066 c           newelm - number of elements to be computed in the new
00067 c                    diagonal
00068 c           error  - error = abs(e1-e0)+abs(e2-e1)+abs(new-e2)
00069 c           result - the element in the new diagonal with least value
00070 c                    of error
00071 c
00072 c           machine dependent constants
00073 c           ---------------------------
00074 c
00075 c           epmach is the largest relative spacing.
00076 c           oflow is the largest positive magnitude.
00077 c           limexp is the maximum number of elements the epsilon
00078 c           table can contain. if this number is reached, the upper
00079 c           diagonal of the epsilon table is deleted.
00080 c
00081 c***first executable statement  qelg
00082       epmach = r1mach(4)
00083       oflow = r1mach(2)
00084       nres = nres+1
00085       abserr = oflow
00086       result = epstab(n)
00087       if(n.lt.3) go to 100
00088       limexp = 50
00089       epstab(n+2) = epstab(n)
00090       newelm = (n-1)/2
00091       epstab(n) = oflow
00092       num = n
00093       k1 = n
00094       do 40 i = 1,newelm
00095         k2 = k1-1
00096         k3 = k1-2
00097         res = epstab(k1+2)
00098         e0 = epstab(k3)
00099         e1 = epstab(k2)
00100         e2 = res
00101         e1abs = abs(e1)
00102         delta2 = e2-e1
00103         err2 = abs(delta2)
00104         tol2 = amax1(abs(e2),e1abs)*epmach
00105         delta3 = e1-e0
00106         err3 = abs(delta3)
00107         tol3 = amax1(e1abs,abs(e0))*epmach
00108         if(err2.gt.tol2.or.err3.gt.tol3) go to 10
00109 c
00110 c           if e0, e1 and e2 are equal to within machine
00111 c           accuracy, convergence is assumed.
00112 c           result = e2
00113 c           abserr = abs(e1-e0)+abs(e2-e1)
00114 c
00115         result = res
00116         abserr = err2+err3
00117 c ***jump out of do-loop
00118         go to 100
00119    10   e3 = epstab(k1)
00120         epstab(k1) = e1
00121         delta1 = e1-e3
00122         err1 = abs(delta1)
00123         tol1 = amax1(e1abs,abs(e3))*epmach
00124 c
00125 c           if two elements are very close to each other, omit
00126 c           a part of the table by adjusting the value of n
00127 c
00128         if(err1.le.tol1.or.err2.le.tol2.or.err3.le.tol3) go to 20
00129         ss = 0.1e+01/delta1+0.1e+01/delta2-0.1e+01/delta3
00130         epsinf = abs(ss*e1)
00131 c
00132 c           test to detect irregular behaviour in the table, and
00133 c           eventually omit a part of the table adjusting the value
00134 c           of n.
00135 c
00136         if(epsinf.gt.0.1e-03) go to 30
00137    20   n = i+i-1
00138 c ***jump out of do-loop
00139         go to 50
00140 c
00141 c           compute a new element and eventually adjust
00142 c           the value of result.
00143 c
00144    30   res = e1+0.1e+01/ss
00145         epstab(k1) = res
00146         k1 = k1-2
00147         error = err2+abs(res-e2)+err3
00148         if(error.gt.abserr) go to 40
00149         abserr = error
00150         result = res
00151    40 continue
00152 c
00153 c           shift the table.
00154 c
00155    50 if(n.eq.limexp) n = 2*(limexp/2)-1
00156       ib = 1
00157       if((num/2)*2.eq.num) ib = 2
00158       ie = newelm+1
00159       do 60 i=1,ie
00160         ib2 = ib+2
00161         epstab(ib) = epstab(ib2)
00162         ib = ib2
00163    60 continue
00164       if(num.eq.n) go to 80
00165       indx = num-n+1
00166       do 70 i = 1,n
00167         epstab(i)= epstab(indx)
00168         indx = indx+1
00169    70 continue
00170    80 if(nres.ge.4) go to 90
00171       res3la(nres) = result
00172       abserr = oflow
00173       go to 100
00174 c
00175 c           compute error estimate
00176 c
00177    90 abserr = abs(result-res3la(3))+abs(result-res3la(2))
00178      *  +abs(result-res3la(1))
00179       res3la(1) = res3la(2)
00180       res3la(2) = res3la(3)
00181       res3la(3) = result
00182   100 abserr = amax1(abserr,0.5e+01*epmach*abs(result))
00183       return
00184       end
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines