* E04ABF Example Program Text * Mark 17 Revised. NAG Copyright 1995. * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Local Scalars .. DOUBLE PRECISION A, B, E1, E2, F, X INTEGER IFAIL, MAXCAL * .. External Subroutines .. EXTERNAL E04ABF, FUNCT * .. Executable Statements .. WRITE (NOUT,*) 'E04ABF Example Program Results' * E1 and E2 are set to zero so that E04ABF will reset them to * their default values E1 = 0.0D0 E2 = 0.0D0 * The minimum is known to lie in the range (3.5, 5.0) A = 3.5D0 B = 5.0D0 * Allow 30 calls of FUNCT MAXCAL = 30 IFAIL = 1 * CALL E04ABF(FUNCT,E1,E2,A,B,MAXCAL,X,F,IFAIL) * WRITE (NOUT,*) IF (IFAIL.LT.0) THEN WRITE (NOUT,99996) ' ** E04ABF returned with IFAIL = ', IFAIL ELSE IF (IFAIL.EQ.1) THEN WRITE (NOUT,*) 'Parameter outside expected range' ELSE IF (IFAIL.EQ.2) THEN WRITE (NOUT,*) + 'Results after MAXCAL function evaluations are' WRITE (NOUT,*) END IF WRITE (NOUT,99999) 'The minimum lies in the interval ', A, + ' to ', B WRITE (NOUT,99999) 'Its estimated position is ', X, ',' WRITE (NOUT,99998) 'where the function value is ', F WRITE (NOUT,99997) MAXCAL, 'function evaluations were required' END IF * 99999 FORMAT (1X,A,F10.8,A,F10.8) 99998 FORMAT (1X,A,F7.4) 99997 FORMAT (1X,I2,1X,A) 99996 FORMAT (1X,A,I5) END * SUBROUTINE FUNCT(XC,FC) * Routine to evaluate F(x) at any point in (A, B) * .. Scalar Arguments .. DOUBLE PRECISION FC, XC * .. Intrinsic Functions .. INTRINSIC SIN * .. Executable Statements .. FC = SIN(XC)/XC RETURN END