      SUBROUTINE ORTHOX (NA, AR, NC, AC)
C     ******************************************************************
C     FORTRAN SUBROUTINE FOR ORTHONORMAL POLYNOMIAL EXPANSION
C     ******************************************************************
C     NA = NUMBER OF ARGUMENTS     (N)
C     AR = RECURRENCE COEFFICIENTS (2*M-2 ARRAY)
C     NC = NUMBER OF COEFFICIENTS  (M)
C     AC = POLYNOMIAL COEFFICIENTS (M*M ARRAY)
C
      DIMENSION AR(2), AC(1)
  001 DO 002 N=1,NC
      AC(N)=0.0
  002 CONTINUE
      SN=NA
      RN=SQRT(SN)
      AC(1)=1.0/RN
      IF(NC.EQ.1)RETURN
  003 TM=0.0
      L=NC
      DO 004 N=1,NC
      L=L+1
      AC(L)=(TM-AR(2)*AC(N))/AR(1)
      TM=AC(N)
  004 CONTINUE
      IF(NC.EQ.2)RETURN
  005 DO 007 M=3,NC
      TM=0.0
      J=(M-3)*NC
      DO 006 N=1,NC
      J=J+1
      K=J+NC
      L=K+NC
      AC(L)=(TM-AR(2*M-2)*AC(K)-AR(2*M-5)*AC(J))/AR(2*M-3)
      TM=AC(K)
  006 CONTINUE
  007 CONTINUE
      RETURN
      END
