Blame view

fvn_fnlib/dcbrt.f 1.19 KB
38581db0c   daniau   git-svn-id: https...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
        double precision function dcbrt (x)
  c june 1977 edition.   w. fullerton, c3, los alamos scientific lab.
        double precision x, cbrt2(5), y, cbrtsq,  d9pak, d1mach
        external d1mach, d9pak
  c
        data cbrt2(1) / 0.6299605249 4743658238 3605303639 11 d0 /
        data cbrt2(2) / 0.7937005259 8409973737 5852819636 15 d0 /
        data cbrt2(3) / 1.0 d0 /
        data cbrt2(4) / 1.2599210498 9487316476 7210607278 23 d0 /
        data cbrt2(5) / 1.5874010519 6819947475 1705639272 31 d0 /
  c
        data niter / 0 /
  c
        if (niter.eq.0) niter = 1.443*alog(-.106*alog(0.1*sngl(d1mach(3)))
       1  ) + 1.0
  c
        dcbrt = 0.d0
        if (x.eq.0.d0) return
  c
        call d9upak (dabs(x), y, n)
        ixpnt = n/3
        irem = n - 3*ixpnt + 3
  c
  c the approximation below is a generalized chebyshev series converted
  c to polynomial form.  the approx is nearly best in the sense of
  c relative error with 4.085 digits accuracy.
  c
        z = y
        dcbrt = .439581e0 + z*(.928549e0 + z*(-.512653e0 + z*.144586e0))
  c
        do 10 iter=1,niter
          cbrtsq = dcbrt*dcbrt
          dcbrt = dcbrt + (y-dcbrt*cbrtsq)/(3.d0*cbrtsq)
   10   continue
  c
        dcbrt = d9pak (cbrt2(irem)*dsign(dcbrt,x), ixpnt)
        return
  c
        end