      SUBROUTINE NEWTON (FUNC,A,B,N,S,IER)
C
      IMPLICIT REAL*8(A-H,O-Z)
      COMPLEX*16 FUNC,Y,FX,Q,S
C
      IER = 0
      IF( N-1 ) 100,110,110
  100 IER=2000
      S=(0.D0,0.D0)
      GO TO 9999
      IF(A.EQ.B)THEN
        IER=2000
        GO TO 9999
      END IF
C
  110 H=(B-A)/N
      Y   = FUNC(A)
      Q=(0.D0,0.D0)
C
      DO  120 I=1,N
      X=A+H*I
      FX = FUNC(X)
      Q   = Q+H*(Y+FX)/2.D0
      Y   = FX
  120 CONTINUE
C
      S = Q
 9999 CONTINUE
      IER=0
      RETURN
C
      END
