PROGRAM FUNCTIONAL
C=======================================================================
C        JUST COMPUTES FUNCTIONL AS A FUNCTION OF DELTA Y1
C=======================================================================
      IMPLICIT REAL * 8 ( A-H , O-Z )
      PARAMETER ( N = 3, ALPHA=1., XST=0., XEN=1., NSEG=100, MULTI=10 )
      DIMENSION SAI(N) , W(N)
      COMMON / DEL / DELTAX, DY
C=======================================================================
C            THREE-SAMPLING-POINT GAUSS INTEGRATION METHOD
C            N: NUMBER OF SAMPLING POINTS IN EACH SEGMENET
C   SAI(I) & W(I): NON-DIMENSIONALIZED COORDINATE & WEIGHTING FACTOR
      DATA SAI/-0.7745966692415D0,0.0000000000000D0, 0.7745966692415D0/
      DATA W  / 0.5555555555555D0,0.8888888888888D0, 0.5555555555555D0/
C=======================================================================
C   DELTAX: SPACIAL DEFERENTIAL LENGTH FOR DERIVATIVE EVALUATION.
      DELTAX = ( XEN - XST ) / ( MULTI * NSEG )
C=======================================================================
      OPEN (1,FILE='FUNC.OUT', STATUS='UNKNOWN' )
      DO I = 1 , 14
      DY = DFLOAT(I)/10.-0.1
      CALL INTE ( ALPHA, XST, XEN, NSEG, N, SAI, W, C1 )
      WRITE(1,*) DY, C1
      END DO
      CLOSE (1)
      STOP
      END
C
C
      SUBROUTINE INTE ( ALPHA,XST,XEN,NSEG, N,SAI,W, TOTAL )
      IMPLICIT REAL * 8 ( A-H , O-Z )
      DIMENSION SAI(N) , W(N)
      TOTAL = 0.
      DX = ( XEN - XST ) / NSEG
      DO I = 1 , NSEG
      X1 = DX*(I-1)
      X2 = X1 + DX
      SUM = 0.
      SH  = ( X2 - X1 ) / 2.
      AVE = ( X1 + X2 ) / 2.
      DO J = 1 , N
      X = SH * SAI(J) + AVE
      SUM = SUM + F(X) * W(J)
      END DO
      TOTAL = TOTAL + SH * SUM
      END DO
      RETURN
      END
C
C
      FUNCTION F(X)
      IMPLICIT REAL * 8 ( A-H , O-Z )
      F = (-DYDX(X)**2 + Y(X)**2)/2.
      RETURN
      END
C
C
      FUNCTION DELTAY(X)
      IMPLICIT REAL * 8 ( A-H , O-Z )
      COMMON / DEL / DELTAX, DY
      FAI1 = X*(1.D0-X)
      DELTAY = DY*FAI1
      RETURN
      END
C
C
      FUNCTION Y(X)
      IMPLICIT REAL * 8 ( A-H , O-Z )
      COMMON / DEL / DELTAX, DY
      Y = DSIN(X)/DSIN(1.D0) + DELTAY(X)
      RETURN
      END
C
C
      FUNCTION DYDX(X)
      IMPLICIT REAL * 8 ( A-H , O-Z )
      COMMON / DEL / DELTAX, DY
      DYDX = ( Y(X+DELTAX) - Y(X-DELTAX) ) / ( 2.*DELTAX )
      RETURN
      END