      FUNCTION EPSIL(FMX,FMIN,DFM,NPT,FPCC,ICC,NCALL,KEY)
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C
      FMXL = FMX
      FMINL = FMIN
      DFML = DFM
      FPCCL = FPCC
      ICCL = ICC
C
C  SLOWER STRETCHING IF KEY = 2
C
      IF(KEY.EQ.2) GO TO 50
C
      FNPTM2 = NPT-2
      IF(NCALL.EQ.1) EPS = (FMXL/DFML)**(1./FNPTM2)-1.0
C
      DO 3 NIT = 1,ICCL
      EP1 = EPS+1.
      EP1TN = EP1**FNPTM2
      DFMOE = DFML/EPS
      F = FMXL-FMINL-DFMOE*(EP1TN*EP1-1.0)
      IF(ABS(F).LT.FPCCL) GO TO 4
      FPN = DFMOE*FNPTM2*EP1TN
      EPS = EPS+F/FPN
    3 CONTINUE
      GO TO 5
   50 CONTINUE
      IF(NCALL.EQ.1) EPS=20.
      DO 11 NIT=1,ICCL
      SUMG = 0.0
      SUMGP = 0.0
      DO 12 M = 2,NPT
      N = M-2
      GN = (1.0+EPS/SQRT(FLOAT(N+4)))**N
      GPN = N*(1.0+EPS/SQRT(FLOAT(N+4)))**(N-1)*(1.0/SQRT(FLOAT(N+4)))
      SUMG = SUMG+GN
   12 SUMGP = SUMGP+GPN
      F = FMXL-FMINL-DFML*SUMG
      IF(ABS(F).LT.FPCCL) GO TO 4
      FP=-DFML*SUMGP
   11 EPS = EPS-F/FP
C
    5 CONTINUE
      EPSIL = EPS
      WRITE(*,100)
      RETURN
    4 EPSIL = EPS
      WRITE(*,101) EPSIL,F,NIT
      RETURN
C
  100 FORMAT(/40HEXCEEDED MAX NO. OF ITERATIONS IN EPSIL.)
  101 FORMAT(/6HEPSIL=,F12.5,5X,7H AND F=,F12.5,5X,6HAFTER ,I3,
     * 12H ITERATIONS.)
C
      END
