! D01ARF Example Program Text
! Mark 26.2 Release. NAG Copyright 2017.
Module d01arfe_mod
! D01ARF Example Program Module:
! Parameters and User-defined Routines
! .. Use Statements ..
Use nag_library, Only: nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Accessibility Statements ..
Private
Public :: f1, f2
! .. Parameters ..
Integer, Parameter, Public :: maxrul = 0, nout = 6
Contains
Function f1(x)
! .. Function Return Value ..
Real (Kind=nag_wp) :: f1
! .. Scalar Arguments ..
Real (Kind=nag_wp), Intent (In) :: x
! .. Executable Statements ..
f1 = 4.0E0_nag_wp/(1.0E0_nag_wp+x*x)
Return
End Function f1
Function f2(x)
! .. Function Return Value ..
Real (Kind=nag_wp) :: f2
! .. Scalar Arguments ..
Real (Kind=nag_wp), Intent (In) :: x
! .. Executable Statements ..
f2 = x**0.125E0_nag_wp
Return
End Function f2
End Module d01arfe_mod
Program d01arfe
! D01ARF Example Main Program
! .. Use Statements ..
Use d01arfe_mod, Only: f1, f2, maxrul, nout
Use nag_library, Only: d01arf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Local Scalars ..
Real (Kind=nag_wp) :: a, absacc, acc, ans, b, relacc
Integer :: ifail, iparm, n
! .. Local Arrays ..
Real (Kind=nag_wp) :: alpha(390)
! .. Executable Statements ..
Write (nout,*) 'D01ARF Example Program Results'
relacc = 0.0E0_nag_wp
absacc = 1.0E-5_nag_wp
! Definite integral of F1(x) - no expansion
iparm = 0
a = 0.0E0_nag_wp
b = 1.0E0_nag_wp
Write (nout,*)
Write (nout,*) 'Definite integral of 4/(1+x*x) over (0,1)'
ifail = -1
Call d01arf(a,b,f1,relacc,absacc,maxrul,iparm,acc,ans,n,alpha,ifail)
Select Case (ifail)
Case (:-1)
Go To 100
Case (0,1)
Write (nout,99999) 'Estimated value of the integral =', ans
Write (nout,99998) 'Estimated absolute error =', acc
Write (nout,99997) 'Number of points used =', n
End Select
! Definite integral of F2(x) - with expansion
iparm = 1
a = 1.0E0_nag_wp
b = 2.0E0_nag_wp
Write (nout,*)
Write (nout,*) 'Definite integral of x**(1/8) over (1,2)'
ifail = -1
Call d01arf(a,b,f2,relacc,absacc,maxrul,iparm,acc,ans,n,alpha,ifail)
Select Case (ifail)
Case (:-1)
Go To 100
Case (0,1)
Write (nout,99999) 'Estimated value of the integral =', ans
Write (nout,99998) 'Estimated absolute error =', acc
Write (nout,99997) 'Number of points used =', n
End Select
! Indefinite integral of F2(x)
iparm = 2
a = 1.2E0_nag_wp
b = 1.8E0_nag_wp
Write (nout,*)
Write (nout,*) 'Indefinite integral of x**(1/8) over (1.2,1.8)'
ifail = 0
Call d01arf(a,b,f2,relacc,absacc,maxrul,iparm,acc,ans,n,alpha,ifail)
Write (nout,99999) 'Estimated value of the integral =', ans
100 Continue
99999 Format (1X,A,F9.5)
99998 Format (1X,A,E10.2)
99997 Format (1X,A,I4)
End Program d01arfe