*     G05YDF Example Program Text
*     Mark 21 Release. NAG Copyright 2004.
*     .. Parameters ..
      INTEGER          NOUT, IDIM, JDIM
      PARAMETER        (NOUT=6,IDIM=15,JDIM=16)
*     .. Local Scalars ..
      DOUBLE PRECISION SUM, VSBL
      INTEGER          I, IFAIL, NTIMES
*     .. Local Arrays ..
      DOUBLE PRECISION QUASI(2,JDIM)
      INTEGER          IREF(406)
*     .. External Functions ..
      DOUBLE PRECISION FUN
      EXTERNAL         FUN
*     .. External Subroutines ..
      EXTERNAL         G05YCF, G05YDF
*     .. Intrinsic Functions ..
      INTRINSIC        DBLE
*     .. Executable Statements ..
      WRITE (NOUT,99999) 'G05YDF Example Program Results'
      NTIMES = 5000
      IFAIL = 0
*
      CALL G05YCF(IDIM,IREF,IFAIL)
*
      SUM = 0.0D0
      DO 20 I = 1, NTIMES
*
         CALL G05YDF(2,QUASI,IREF,IFAIL)
*
         SUM = SUM + FUN(IDIM,2,QUASI)
   20 CONTINUE
      VSBL = SUM/DBLE(2*NTIMES)
      WRITE (NOUT,99999)
      WRITE (NOUT,99999) 'Value of integral = ', VSBL
      STOP
*
99999 FORMAT (A,F8.4)
      END
*
      DOUBLE PRECISION FUNCTION FUN(IDIM,N,X)
*     .. Scalar Arguments ..
      INTEGER                       IDIM, N
*     .. Array Arguments ..
      DOUBLE PRECISION              X(N,IDIM)
*     .. Local Scalars ..
      DOUBLE PRECISION              TMP, TMP1
      INTEGER                       J
*     .. Intrinsic Functions ..
      INTRINSIC                     ABS
*     .. Executable Statements ..
      TMP = 1.0D0
      TMP1 = 1.0D0
      DO 20 J = 1, IDIM
         TMP = TMP*ABS(4.0D0*X(1,J)-2.0D0)
         TMP1 = TMP1*ABS(4.0D0*X(2,J)-2.0D0)
   20 CONTINUE
      FUN = TMP + TMP1
      RETURN
      END
