        PROGRAM D4R8

C       Driver for routine QGAUS

        PARAMETER(NVAL=10)

        x1=0.

        x2=5.

        DX=(X2-X1)/NVAL

        WRITE(*,'(/1X,A,T12,A,T23,A/)') '0.0 to','QGAUS','Expected'

        DO 11 I=1,NVAL

                X=X1+I*DX

                CALL QGAUS(X1,X,SS)

                WRITE(*,'(1X,F5.2,2F12.6)') X,SS,

     *                  -(1.0+X)*EXP(-X)+(1.0+X1)*EXP(-X1)

11      CONTINUE

        END



        FUNCTION FUNC(X)

        FUNC=X*EXP(-X)

        END

C

      SUBROUTINE QGAUS(A,B,SS)

      DIMENSION X(10),W(10)

      DATA X/.1488743389,.4333953941,.6794095682,.8650633666,.9739065285

     *,-.1488743389,-.4333953941,-.6794095682,-.8650633666,-.9739065285

     */

      DATA W/.2955242247,.2692667193,.2190863625,.1494513491,.0666713443

     *,.2955242247,.2692667193,.2190863625,.1494513491,.0666713443

     */

      XM=0.5*(B+A)

      XR=0.5*(B-A)

      SS=0

      DO 11 J=1,10

        DX=XR*X(J)

        SS=SS+W(J)*(FUNC(XM+DX))

11    CONTINUE

      SS=XR*SS

      RETURN

      END

