      SUBROUTINE LAGINT (X,Y,N,XINT,YOUT)
C
C   FROM APPLIED NUMERICAL ANALYSIS, THIRD EDITION (GERALD / WHEATLEY)
C   CHAPTER 3, PROGRAM 1
C
C  --------------------------------------------------------------
C
C   THIS SUBROUTINE PERFORMS LAGRANGIAN INTERPOLATION WITHIN A SET
C   OF (X,Y) PAIRS TO GIVE THE Y VALUE CORRESPONDING TO XINT.  THE
C   DEGREE OF THE INTERPOLATING POLYNOMIAL IS ONE LESS THAN THE
C   NUMBER OF POINTS SUPPLIED.
C
C  --------------------------------------------------------------
C
C   PARAMETERS ARE:
C   X      ARRAY OF VALUES OF THE INDEPENDENT VARIABLE
C   Y      ARRAY OF FUNCTION VALUES CORRESPONDING TO X
C   N      NUMBER OF POINTS
C   XINT   THE X-VALUE FOR WHICH ESTIMATE OF Y IS DESIRED
C   YOUT   THE Y VALUE RETURNED TO CALLER
C
C  --------------------------------------------------------------
C
      DIMENSION X(N),Y(N)
C
C  --------------------------------------------------------------
C
      YOUT=0.0
      DO 20 I=1,N
         TERM = Y(I)
         DO 10 J= 1,N
            IF (I.NE.J) THEN
               TERM = TERM * (XINT - X(J))/(X(I)-X(J))
            END IF
   10    CONTINUE
         YOUT = YOUT + TERM
   20 CONTINUE
      RETURN
      END
