! D01BDF Example Program Text ! Mark 23 Release. NAG Copyright 2011. MODULE d01bdfe_mod ! D01BDF Example Program Module: ! Parameters and User-defined Routines ! .. Use Statements .. USE nag_library, ONLY : nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nout = 6 CONTAINS FUNCTION f(x) ! .. Use Statements .. USE nag_library, ONLY : x01aaf ! .. Implicit None Statement .. IMPLICIT NONE ! .. Function Return Value .. REAL (KIND=nag_wp) :: f ! .. Scalar Arguments .. REAL (KIND=nag_wp), INTENT (IN) :: x ! .. Intrinsic Functions .. INTRINSIC sin ! .. Executable Statements .. f = (x**2)*sin(10.0E0_nag_wp*x01aaf(f)*x) RETURN END FUNCTION f END MODULE d01bdfe_mod PROGRAM d01bdfe ! D01BDF Example Main Program ! .. Use Statements .. USE nag_library, ONLY : d01bdf, nag_wp USE d01bdfe_mod, ONLY : f, nout ! .. Implicit None Statement .. IMPLICIT NONE ! .. Local Scalars .. REAL (KIND=nag_wp) :: a, abserr, b, epsabs, epsrel, & result ! .. Intrinsic Functions .. INTRINSIC abs, max ! .. Executable Statements .. WRITE (nout,*) 'D01BDF Example Program Results' epsabs = 0.0E0_nag_wp epsrel = 1.0E-04_nag_wp a = 0.0E0_nag_wp b = 1.0E0_nag_wp CALL d01bdf(f,a,b,epsabs,epsrel,result,abserr) WRITE (nout,*) WRITE (nout,99999) 'A - lower limit of integration = ', a WRITE (nout,99999) 'B - upper limit of integration = ', b WRITE (nout,99998) 'EPSABS - absolute accuracy requested = ', epsabs WRITE (nout,99998) 'EPSREL - relative accuracy requested = ', epsrel WRITE (nout,*) WRITE (nout,99997) 'RESULT - approximation to the integral = ', result WRITE (nout,99998) 'ABSERR - estimate to the absolute error = ', abserr WRITE (nout,*) IF (abserr>max(epsabs,epsrel*abs(result))) THEN WRITE (nout,*) & 'Warning - requested accuracy may not have been achieved' END IF 99999 FORMAT (1X,A,F10.4) 99998 FORMAT (1X,A,E9.2) 99997 FORMAT (1X,A,F9.5) END PROGRAM d01bdfe