* E04ABA Example Program Text * Mark 20 Release. NAG Copyright 2001. * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Local Scalars .. DOUBLE PRECISION A, B, EPS, F, T, X INTEGER IFAIL, MAXCAL * .. Local Arrays .. DOUBLE PRECISION RUSER(1) INTEGER IUSER(1) * .. External Subroutines .. EXTERNAL E04ABA, FUNCT * .. Executable Statements .. WRITE (NOUT,*) 'E04ABA Example Program Results' * EPS and T are set to zero so that E04ABA will reset them to * their default values EPS = 0.0D0 T = 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 E04ABA(FUNCT,EPS,T,A,B,MAXCAL,X,F,IUSER,RUSER,IFAIL) * WRITE (NOUT,*) 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 STOP * 99999 FORMAT (1X,A,F10.8,A,F10.8) 99998 FORMAT (1X,A,F7.4) 99997 FORMAT (1X,I2,1X,A) END * SUBROUTINE FUNCT(XC,FC,IUSER,RUSER) * Routine to evaluate F(x) at any point in (A, B) * .. Scalar Arguments .. DOUBLE PRECISION FC, XC * .. Array Arguments .. DOUBLE PRECISION RUSER(*) INTEGER IUSER(*) * .. Intrinsic Functions .. INTRINSIC SIN * .. Executable Statements .. FC = SIN(XC)/XC RETURN END