C******************************************************
C
C     Dichotomous search technique for 
C     one-dimensional minimization.
C
C******************************************************
C     Neculai Andrei, 
C     Research Institute for Informatics
C     Advanced Modeling and Optimization Laboratory    
C****************************************************** 
C
	SUBROUTINE L4(N,X,S,BL)
	DOUBLE PRECISION X(N),S(N),BL
	DOUBLE PRECISION EPS,A,B,C,C1,C2
	DOUBLE PRECISION XT(40),F1,F2
C
	COMMON /PREC/EPS
	COMMON /TYPE/NO
	COMMON /NOF/NBL
C
	IF(NO.EQ.6) THEN
	OPEN(6,FILE='PRINT.DAT',ACCESS='SEQUENTIAL',
     +         FORM='FORMATTED')
	ENDIF
C
	NBL=0 
	JTYPE=0
	EPS1=EPS/10
	A=0.0
	B=1.0
C
1     C=A+(B-A)/2.
C
              IF(JTYPE.EQ.1) WRITE(NO,14)A,B
14            FORMAT(10X,'Interval: A=',F12.6,5X,'B = ',F12.6)
C
	C1=C+EPS1/2.
	DO 2 I=1,N
2	XT(I)=X(I)+C1*S(I)
	CALL FUNC(N,XT,F1)
	NBL=NBL+1
C
              IF(JTYPE.EQ.1) WRITE(NO,10)C1,F1
10            FORMAT(10X,'C1 = ',F12.6,5X,'F1 = ',F18.6)
C
	C2=C-EPS1/2.
	DO 3 I=1,N
3	XT(I)=X(I)+C2*S(I)
	CALL FUNC(N,XT,F2)
	NBL=NBL+1
C
              IF(JTYPE.EQ.1) WRITE(NO,11)C2,F2
11            FORMAT(10X,'C2 = ',F12.6,5X,'F2 = ',F18.6)
C
	IF(F2.LT.F1) THEN
	B=C1
	ELSE
	A=C2
	ENDIF
C
	IF(DABS(B-A).LE.EPS) GO TO 4
	GO TO 1
4	BL=C
C             
              IF(JTYPE.EQ.1) WRITE(NO,100)BL
100           FORMAT(10X,'BL = ',F18.6,/,
     +               10X,'Number of Func. Eval. = ',I5)
C
	RETURN
	END
C
C*******************************Last card of L4.FOR