      double precision function dcosdg (x)
c june 1977 edition.   w. fullerton, c3, los alamos scientific lab.
      double precision x, raddeg, dcos
      external dcos
      data raddeg / 0.0174532925 1994329576 9236907684 886 d0 /
c
      dcosdg = dcos (raddeg*x)
c
      if (dmod(x,90.d0).ne.0.d0) return
      n = dabs(x)/90.d0 + 0.5d0
      n = mod (n, 2)
      if (n.eq.0) dcosdg = dsign (1.0d0, dcosdg)
      if (n.eq.1) dcosdg = 0.0d0
c
      return
      end