exprel.f 1.01 KB
function exprel (x)
c august 1977 edition.  w. fullerton, c3, los alamos scientific lab.
c
c evaluate  exprel(x) = (exp(x) - 1.0) / x.   for small abs(x) the
c taylor series is used.  if x is negative the reflection formula
c         exprel(x) = exp(x) * exprel(abs(x))
c may be used  this reflection formula will be of use when the
c evaluation for small abs(x) is done by chebyshev series rather than
c taylor series.
c
      external  r1mach
      data nterms, xbnd / 0, 0.0 /
c
      if (nterms.ne.0) go to 10
      alneps = alog(r1mach(3))
      xn = 3.72 - 0.3*alneps
      xln = alog((xn+1.0)/1.36)
      nterms = xn - (xn*xln+alneps)/(xln+1.36) + 1.5
      xbnd = r1mach(3)
c
 10   absx = abs(x)
      if (absx.le.0.5) go to 20
      call entsrc (irold, 1)
      exprel = (exp(x)-1.0)/x
      call entsrc (ir, irold)
      return
c
 20   exprel = 1.0
      if (absx.lt.xbnd) return
c
      exprel = 0.0
      do 30 i=1,nterms
        exprel = 1.0 + exprel*x/float(nterms+2-i)
 30   continue
c
      return
      end