besk1.f 1.91 KB
function besk1 (x)
c july 1980 version.  w. fullerton, c3, los alamos scientific lab.
      dimension bk1cs(11)
      external  besi1, besk1e, csevl, inits, r1mach
c
c series for bk1        on the interval  0.          to  4.00000d+00
c                                        with weighted error   7.02e-18
c                                         log weighted error  17.15
c                               significant figures required  16.73
c                                    decimal places required  17.67
c
      data bk1 cs( 1) /    .0253002273 389477705e0 /
      data bk1 cs( 2) /   -.3531559607 76544876e0 /
      data bk1 cs( 3) /   -.1226111808 22657148e0 /
      data bk1 cs( 4) /   -.0069757238 596398643e0 /
      data bk1 cs( 5) /   -.0001730288 957513052e0 /
      data bk1 cs( 6) /   -.0000024334 061415659e0 /
      data bk1 cs( 7) /   -.0000000221 338763073e0 /
      data bk1 cs( 8) /   -.0000000001 411488392e0 /
      data bk1 cs( 9) /   -.0000000000 006666901e0 /
      data bk1 cs(10) /   -.0000000000 000024274e0 /
      data bk1 cs(11) /   -.0000000000 000000070e0 /
c
      data ntk1, xmin, xsml, xmax /0, 0., 0., 0. /
c
      if (ntk1.ne.0) go to 10
      ntk1 = inits (bk1cs, 11, 0.1*r1mach(3))
      xmin = exp (amax1(alog(r1mach(1)), -alog(r1mach(2))) + .01)
      xsml = sqrt (4.0*r1mach(3))
      xmax = -alog(r1mach(1))
      xmax = xmax - 0.5*xmax*alog(xmax)/(xmax+0.5) - 0.01
c
 10   if (x.le.0.) call seteru (29hbesk1   x is zero or negative, 29,
     1  2, 2)
      if (x.gt.2.0) go to 20
c
      if (x.lt.xmin) call seteru (31hbesk1   x so small k1 overflows,
     1  31, 3, 2)
      y = 0.
      if (x.gt.xsml) y = x*x
      besk1 = alog(0.5*x)*besi1(x) +
     1  (0.75 + csevl (.5*y-1., bk1cs, ntk1))/x
      return
c
 20   besk1 = 0.
      if (x.gt.xmax) call seteru (30hbesk1   x so big k1 underflows,
     1  30, 1, 0)
      if (x.gt.xmax) return
c
      besk1 = exp(-x) * besk1e(x)
c
      return
      end