1
subroutine dqk31(f,a,b,result,abserr,resabs,resasc)
2
c***begin prologue dqk31
3
c***date written 800101 (yymmdd)
4
c***revision date 830518 (yymmdd)
5
c***category no. h2a1a2
6
c***keywords 31-point gauss-kronrod rules
7
c***author piessens,robert,appl. math. & progr. div. - k.u.leuven
8
c de doncker,elise,appl. math. & progr. div. - k.u.leuven
9
c***purpose to compute i = integral of f over (a,b) with error
11
c j = integral of abs(f) over (a,b)
15
c standard fortran subroutine
16
c double precision version
20
c f - double precision
21
c function subprogram defining the integrand
22
c function f(x). the actual name for f needs to be
23
c declared e x t e r n a l in the calling program.
25
c a - double precision
26
c lower limit of integration
28
c b - double precision
29
c upper limit of integration
32
c result - double precision
33
c approximation to the integral i
34
c result is computed by applying the 31-point
35
c gauss-kronrod rule (resk), obtained by optimal
36
c addition of abscissae to the 15-point gauss
39
c abserr - double precison
40
c estimate of the modulus of the modulus,
41
c which should not exceed abs(i-result)
43
c resabs - double precision
44
c approximation to the integral j
46
c resasc - double precision
47
c approximation to the integral of abs(f-i/(b-a))
51
c***routines called d1mach
52
c***end prologue dqk31
53
double precision a,absc,abserr,b,centr,dabs,dhlgth,dmax1,dmin1,
54
* d1mach,epmach,f,fc,fsum,fval1,fval2,fv1,fv2,hlgth,resabs,resasc,
55
* resg,resk,reskh,result,uflow,wg,wgk,xgk
59
dimension fv1(15),fv2(15),xgk(16),wgk(16),wg(8)
61
c the abscissae and weights are given for the interval (-1,1).
62
c because of symmetry only the positive abscissae and their
63
c corresponding weights are given.
65
c xgk - abscissae of the 31-point kronrod rule
66
c xgk(2), xgk(4), ... abscissae of the 15-point
68
c xgk(1), xgk(3), ... abscissae which are optimally
69
c added to the 15-point gauss rule
71
c wgk - weights of the 31-point kronrod rule
73
c wg - weights of the 15-point gauss rule
76
c gauss quadrature weights and kronron quadrature abscissae and weights
77
c as evaluated with 80 decimal digit arithmetic by l. w. fullerton,
78
c bell labs, nov. 1981.
80
data wg ( 1) / 0.0307532419 9611726835 4628393577 204 d0 /
81
data wg ( 2) / 0.0703660474 8810812470 9267416450 667 d0 /
82
data wg ( 3) / 0.1071592204 6717193501 1869546685 869 d0 /
83
data wg ( 4) / 0.1395706779 2615431444 7804794511 028 d0 /
84
data wg ( 5) / 0.1662692058 1699393355 3200860481 209 d0 /
85
data wg ( 6) / 0.1861610000 1556221102 6800561866 423 d0 /
86
data wg ( 7) / 0.1984314853 2711157645 6118326443 839 d0 /
87
data wg ( 8) / 0.2025782419 2556127288 0620199967 519 d0 /
89
data xgk ( 1) / 0.9980022986 9339706028 5172840152 271 d0 /
90
data xgk ( 2) / 0.9879925180 2048542848 9565718586 613 d0 /
91
data xgk ( 3) / 0.9677390756 7913913425 7347978784 337 d0 /
92
data xgk ( 4) / 0.9372733924 0070590430 7758947710 209 d0 /
93
data xgk ( 5) / 0.8972645323 4408190088 2509656454 496 d0 /
94
data xgk ( 6) / 0.8482065834 1042721620 0648320774 217 d0 /
95
data xgk ( 7) / 0.7904185014 4246593296 7649294817 947 d0 /
96
data xgk ( 8) / 0.7244177313 6017004741 6186054613 938 d0 /
97
data xgk ( 9) / 0.6509967412 9741697053 3735895313 275 d0 /
98
data xgk ( 10) / 0.5709721726 0853884753 7226737253 911 d0 /
99
data xgk ( 11) / 0.4850818636 4023968069 3655740232 351 d0 /
100
data xgk ( 12) / 0.3941513470 7756336989 7207370981 045 d0 /
101
data xgk ( 13) / 0.2991800071 5316881216 6780024266 389 d0 /
102
data xgk ( 14) / 0.2011940939 9743452230 0628303394 596 d0 /
103
data xgk ( 15) / 0.1011420669 1871749902 7074231447 392 d0 /
104
data xgk ( 16) / 0.0000000000 0000000000 0000000000 000 d0 /
106
data wgk ( 1) / 0.0053774798 7292334898 7792051430 128 d0 /
107
data wgk ( 2) / 0.0150079473 2931612253 8374763075 807 d0 /
108
data wgk ( 3) / 0.0254608473 2671532018 6874001019 653 d0 /
109
data wgk ( 4) / 0.0353463607 9137584622 2037948478 360 d0 /
110
data wgk ( 5) / 0.0445897513 2476487660 8227299373 280 d0 /
111
data wgk ( 6) / 0.0534815246 9092808726 5343147239 430 d0 /
112
data wgk ( 7) / 0.0620095678 0067064028 5139230960 803 d0 /
113
data wgk ( 8) / 0.0698541213 1872825870 9520077099 147 d0 /
114
data wgk ( 9) / 0.0768496807 5772037889 4432777482 659 d0 /
115
data wgk ( 10) / 0.0830805028 2313302103 8289247286 104 d0 /
116
data wgk ( 11) / 0.0885644430 5621177064 7275443693 774 d0 /
117
data wgk ( 12) / 0.0931265981 7082532122 5486872747 346 d0 /
118
data wgk ( 13) / 0.0966427269 8362367850 5179907627 589 d0 /
119
data wgk ( 14) / 0.0991735987 2179195933 2393173484 603 d0 /
120
data wgk ( 15) / 0.1007698455 2387559504 4946662617 570 d0 /
121
data wgk ( 16) / 0.1013300070 1479154901 7374792767 493 d0 /
124
c list of major variables
125
c -----------------------
126
c centr - mid point of the interval
127
c hlgth - half-length of the interval
129
c fval* - function value
130
c resg - result of the 15-point gauss formula
131
c resk - result of the 31-point kronrod formula
132
c reskh - approximation to the mean value of f over (a,b),
135
c machine dependent constants
136
c ---------------------------
137
c epmach is the largest relative spacing.
138
c uflow is the smallest positive magnitude.
139
c***first executable statement dqk31
143
centr = 0.5d+00*(a+b)
144
hlgth = 0.5d+00*(b-a)
147
c compute the 31-point kronrod approximation to
148
c the integral, and estimate the absolute error.
156
absc = hlgth*xgk(jtw)
157
fval1 = f(centr-absc)
158
fval2 = f(centr+absc)
162
resg = resg+wg(j)*fsum
163
resk = resk+wgk(jtw)*fsum
164
resabs = resabs+wgk(jtw)*(dabs(fval1)+dabs(fval2))
168
absc = hlgth*xgk(jtwm1)
169
fval1 = f(centr-absc)
170
fval2 = f(centr+absc)
174
resk = resk+wgk(jtwm1)*fsum
175
resabs = resabs+wgk(jtwm1)*(dabs(fval1)+dabs(fval2))
178
resasc = wgk(16)*dabs(fc-reskh)
180
resasc = resasc+wgk(j)*(dabs(fv1(j)-reskh)+dabs(fv2(j)-reskh))
183
resabs = resabs*dhlgth
184
resasc = resasc*dhlgth
185
abserr = dabs((resk-resg)*hlgth)
186
if(resasc.ne.0.0d+00.and.abserr.ne.0.0d+00)
187
* abserr = resasc*dmin1(0.1d+01,(0.2d+03*abserr/resasc)**1.5d+00)
188
if(resabs.gt.uflow/(0.5d+02*epmach)) abserr = dmax1
189
* ((epmach*0.5d+02)*resabs,abserr)