2 SUBROUTINE DQNG
(F
, A
, B
, EPSABS
, EPSREL
, RESULT
, ABSERR
, NEVAL
,
4 C***BEGIN PROLOGUE DQNG
5 C***PURPOSE The routine calculates an approximation result to a
6 C given definite integral I = integral of F over (A,B),
7 C hopefully satisfying following claim for accuracy
8 C ABS(I-RESULT).LE.MAX(EPSABS,EPSREL*ABS(I)).
9 C***LIBRARY SLATEC (QUADPACK)
11 C***TYPE DOUBLE PRECISION (QNG-S, DQNG-D)
12 C***KEYWORDS AUTOMATIC INTEGRATOR, GAUSS-KRONROD(PATTERSON) RULES,
13 C NONADAPTIVE, QUADPACK, QUADRATURE, SMOOTH INTEGRAND
14 C***AUTHOR Piessens, Robert
15 C Applied Mathematics and Programming Division
18 C Applied Mathematics and Programming Division
22 C NON-ADAPTIVE INTEGRATION
23 C STANDARD FORTRAN SUBROUTINE
24 C DOUBLE PRECISION VERSION
26 C F - Double precision
27 C Function subprogram defining the integrand function
28 C F(X). The actual name for F needs to be declared
29 C E X T E R N A L in the driver program.
31 C A - Double precision
32 C Lower limit of integration
34 C B - Double precision
35 C Upper limit of integration
37 C EPSABS - Double precision
38 C Absolute accuracy requested
39 C EPSREL - Double precision
40 C Relative accuracy requested
42 C And EPSREL.LT.MAX(50*REL.MACH.ACC.,0.5D-28),
43 C The routine will end with IER = 6.
46 C RESULT - Double precision
47 C Approximation to the integral I
48 C Result is obtained by applying the 21-POINT
49 C GAUSS-KRONROD RULE (RES21) obtained by optimal
50 C addition of abscissae to the 10-POINT GAUSS RULE
51 C (RES10), or by applying the 43-POINT RULE (RES43)
52 C obtained by optimal addition of abscissae to the
53 C 21-POINT GAUSS-KRONROD RULE, or by applying the
54 C 87-POINT RULE (RES87) obtained by optimal addition
55 C of abscissae to the 43-POINT RULE.
57 C ABSERR - Double precision
58 C Estimate of the modulus of the absolute error,
59 C which should EQUAL or EXCEED ABS(I-RESULT)
62 C Number of integrand evaluations
64 C IER - IER = 0 normal and reliable termination of the
65 C routine. It is assumed that the requested
66 C accuracy has been achieved.
67 C IER.GT.0 Abnormal termination of the routine. It is
68 C assumed that the requested accuracy has
71 C IER = 1 The maximum number of steps has been
72 C executed. The integral is probably too
73 C difficult to be calculated by DQNG.
74 C = 6 The input is invalid, because
76 C EPSREL.LT.MAX(50*REL.MACH.ACC.,0.5D-28).
77 C RESULT, ABSERR and NEVAL are set to zero.
80 C***ROUTINES CALLED D1MACH, XERMSG
81 C***REVISION HISTORY (YYMMDD)
83 C 890531 Changed all specific intrinsics to generic. (WRB)
84 C 890531 REVISION DATE from Version 3.2
85 C 891214 Prologue converted to Version 4.0 format. (BAB)
86 C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
89 DOUBLE PRECISION A
,ABSC
,ABSERR
,B
,CENTR
,DHLGTH
,
90 1 D1MACH
,EPMACH
,EPSABS
,EPSREL
,F
,FCENTR
,FVAL
,FVAL1
,FVAL2
,FV1
,FV2
,
91 2 FV3
,FV4
,HLGTH
,RESULT
,RES10
,RES21
,RES43
,RES87
,RESABS
,RESASC
,
92 3 RESKH
,SAVFUN
,UFLOW
,W10
,W21A
,W21B
,W43A
,W43B
,W87A
,W87B
,X1
,X2
,X3
,X4
93 INTEGER IER
,IPX
,K
,L
,NEVAL
96 DIMENSION FV1
(5),FV2
(5),FV3
(5),FV4
(5),X1
(5),X2
(5),X3
(11),X4
(22),
97 1 W10
(5),W21A
(5),W21B
(6),W43A
(10),W43B
(12),W87A
(21),W87B
(23),
100 C THE FOLLOWING DATA STATEMENTS CONTAIN THE
101 C ABSCISSAE AND WEIGHTS OF THE INTEGRATION RULES USED.
103 C X1 ABSCISSAE COMMON TO THE 10-, 21-, 43- AND 87-
105 C X2 ABSCISSAE COMMON TO THE 21-, 43- AND 87-POINT RULE
106 C X3 ABSCISSAE COMMON TO THE 43- AND 87-POINT RULE
107 C X4 ABSCISSAE OF THE 87-POINT RULE
108 C W10 WEIGHTS OF THE 10-POINT FORMULA
109 C W21A WEIGHTS OF THE 21-POINT FORMULA FOR ABSCISSAE X1
110 C W21B WEIGHTS OF THE 21-POINT FORMULA FOR ABSCISSAE X2
111 C W43A WEIGHTS OF THE 43-POINT FORMULA FOR ABSCISSAE X1, X3
112 C W43B WEIGHTS OF THE 43-POINT FORMULA FOR ABSCISSAE X3
113 C W87A WEIGHTS OF THE 87-POINT FORMULA FOR ABSCISSAE X1,
115 C W87B WEIGHTS OF THE 87-POINT FORMULA FOR ABSCISSAE X4
118 C GAUSS-KRONROD-PATTERSON QUADRATURE COEFFICIENTS FOR USE IN
119 C QUADPACK ROUTINE QNG. THESE COEFFICIENTS WERE CALCULATED WITH
120 C 101 DECIMAL DIGIT ARITHMETIC BY L. W. FULLERTON, BELL LABS, NOV 1981.
122 SAVE X1
, W10
, X2
, W21A
, W21B
, X3
, W43A
, W43B
, X4
, W87A
, W87B
123 DATA X1
( 1) / 0.9739065285 1717172007 7964012084 452 D0
/
124 DATA X1
( 2) / 0.8650633666 8898451073 2096688423 493 D0
/
125 DATA X1
( 3) / 0.6794095682 9902440623 4327365114 874 D0
/
126 DATA X1
( 4) / 0.4333953941 2924719079 9265943165 784 D0
/
127 DATA X1
( 5) / 0.1488743389 8163121088 4826001129 720 D0
/
128 DATA W10
( 1) / 0.0666713443 0868813759 3568809893 332 D0
/
129 DATA W10
( 2) / 0.1494513491 5058059314 5776339657 697 D0
/
130 DATA W10
( 3) / 0.2190863625 1598204399 5534934228 163 D0
/
131 DATA W10
( 4) / 0.2692667193 0999635509 1226921569 469 D0
/
132 DATA W10
( 5) / 0.2955242247 1475287017 3892994651 338 D0
/
134 DATA X2
( 1) / 0.9956571630 2580808073 5527280689 003 D0
/
135 DATA X2
( 2) / 0.9301574913 5570822600 1207180059 508 D0
/
136 DATA X2
( 3) / 0.7808177265 8641689706 3717578345 042 D0
/
137 DATA X2
( 4) / 0.5627571346 6860468333 9000099272 694 D0
/
138 DATA X2
( 5) / 0.2943928627 0146019813 1126603103 866 D0
/
139 DATA W21A
( 1) / 0.0325581623 0796472747 8818972459 390 D0
/
140 DATA W21A
( 2) / 0.0750396748 1091995276 7043140916 190 D0
/
141 DATA W21A
( 3) / 0.1093871588 0229764189 9210590325 805 D0
/
142 DATA W21A
( 4) / 0.1347092173 1147332592 8054001771 707 D0
/
143 DATA W21A
( 5) / 0.1477391049 0133849137 4841515972 068 D0
/
144 DATA W21B
( 1) / 0.0116946388 6737187427 8064396062 192 D0
/
145 DATA W21B
( 2) / 0.0547558965 7435199603 1381300244 580 D0
/
146 DATA W21B
( 3) / 0.0931254545 8369760553 5065465083 366 D0
/
147 DATA W21B
( 4) / 0.1234919762 6206585107 7958109831 074 D0
/
148 DATA W21B
( 5) / 0.1427759385 7706008079 7094273138 717 D0
/
149 DATA W21B
( 6) / 0.1494455540 0291690566 4936468389 821 D0
/
151 DATA X3
( 1) / 0.9993333609 0193208139 4099323919 911 D0
/
152 DATA X3
( 2) / 0.9874334029 0808886979 5961478381 209 D0
/
153 DATA X3
( 3) / 0.9548079348 1426629925 7919200290 473 D0
/
154 DATA X3
( 4) / 0.9001486957 4832829362 5099494069 092 D0
/
155 DATA X3
( 5) / 0.8251983149 8311415084 7066732588 520 D0
/
156 DATA X3
( 6) / 0.7321483889 8930498261 2354848755 461 D0
/
157 DATA X3
( 7) / 0.6228479705 3772523864 1159120344 323 D0
/
158 DATA X3
( 8) / 0.4994795740 7105649995 2214885499 755 D0
/
159 DATA X3
( 9) / 0.3649016613 4658076804 3989548502 644 D0
/
160 DATA X3
( 10) / 0.2222549197 7660129649 8260928066 212 D0
/
161 DATA X3
( 11) / 0.0746506174 6138332204 3914435796 506 D0
/
162 DATA W43A
( 1) / 0.0162967342 8966656492 4281974617 663 D0
/
163 DATA W43A
( 2) / 0.0375228761 2086950146 1613795898 115 D0
/
164 DATA W43A
( 3) / 0.0546949020 5825544214 7212685465 005 D0
/
165 DATA W43A
( 4) / 0.0673554146 0947808607 5553166302 174 D0
/
166 DATA W43A
( 5) / 0.0738701996 3239395343 2140695251 367 D0
/
167 DATA W43A
( 6) / 0.0057685560 5976979618 4184327908 655 D0
/
168 DATA W43A
( 7) / 0.0273718905 9324884208 1276069289 151 D0
/
169 DATA W43A
( 8) / 0.0465608269 1042883074 3339154433 824 D0
/
170 DATA W43A
( 9) / 0.0617449952 0144256449 6240336030 883 D0
/
171 DATA W43A
( 10) / 0.0713872672 6869339776 8559114425 516 D0
/
172 DATA W43B
( 1) / 0.0018444776 4021241410 0389106552 965 D0
/
173 DATA W43B
( 2) / 0.0107986895 8589165174 0465406741 293 D0
/
174 DATA W43B
( 3) / 0.0218953638 6779542810 2523123075 149 D0
/
175 DATA W43B
( 4) / 0.0325974639 7534568944 3882222526 137 D0
/
176 DATA W43B
( 5) / 0.0421631379 3519181184 7627924327 955 D0
/
177 DATA W43B
( 6) / 0.0507419396 0018457778 0189020092 084 D0
/
178 DATA W43B
( 7) / 0.0583793955 4261924837 5475369330 206 D0
/
179 DATA W43B
( 8) / 0.0647464049 5144588554 4689259517 511 D0
/
180 DATA W43B
( 9) / 0.0695661979 1235648452 8633315038 405 D0
/
181 DATA W43B
( 10) / 0.0728244414 7183320815 0939535192 842 D0
/
182 DATA W43B
( 11) / 0.0745077510 1417511827 3571813842 889 D0
/
183 DATA W43B
( 12) / 0.0747221475 1740300559 4425168280 423 D0
/
185 DATA X4
( 1) / 0.9999029772 6272923449 0529830591 582 D0
/
186 DATA X4
( 2) / 0.9979898959 8667874542 7496322365 960 D0
/
187 DATA X4
( 3) / 0.9921754978 6068722280 8523352251 425 D0
/
188 DATA X4
( 4) / 0.9813581635 7271277357 1916941623 894 D0
/
189 DATA X4
( 5) / 0.9650576238 5838461912 8284110607 926 D0
/
190 DATA X4
( 6) / 0.9431676131 3367059681 6416634507 426 D0
/
191 DATA X4
( 7) / 0.9158064146 8550720959 1826430720 050 D0
/
192 DATA X4
( 8) / 0.8832216577 7131650137 2117548744 163 D0
/
193 DATA X4
( 9) / 0.8457107484 6241566660 5902011504 855 D0
/
194 DATA X4
( 10) / 0.8035576580 3523098278 8739474980 964 D0
/
195 DATA X4
( 11) / 0.7570057306 8549555832 8942793432 020 D0
/
196 DATA X4
( 12) / 0.7062732097 8732181982 4094274740 840 D0
/
197 DATA X4
( 13) / 0.6515894665 0117792253 4422205016 736 D0
/
198 DATA X4
( 14) / 0.5932233740 5796108887 5273770349 144 D0
/
199 DATA X4
( 15) / 0.5314936059 7083193228 5268948562 671 D0
/
200 DATA X4
( 16) / 0.4667636230 4202284487 1966781659 270 D0
/
201 DATA X4
( 17) / 0.3994248478 5921880473 2101665817 923 D0
/
202 DATA X4
( 18) / 0.3298748771 0618828826 5053371824 597 D0
/
203 DATA X4
( 19) / 0.2585035592 0216155180 2280975429 025 D0
/
204 DATA X4
( 20) / 0.1856953965 6834665201 5917141167 606 D0
/
205 DATA X4
( 21) / 0.1118422131 7990746817 2398359241 362 D0
/
206 DATA X4
( 22) / 0.0373521233 9461987081 4998165437 704 D0
/
207 DATA W87A
( 1) / 0.0081483773 8414917290 0002878448 190 D0
/
208 DATA W87A
( 2) / 0.0187614382 0156282224 3935059003 794 D0
/
209 DATA W87A
( 3) / 0.0273474510 5005228616 1582829741 283 D0
/
210 DATA W87A
( 4) / 0.0336777073 1163793004 6581056957 588 D0
/
211 DATA W87A
( 5) / 0.0369350998 2042790761 4589586742 499 D0
/
212 DATA W87A
( 6) / 0.0028848724 3021153050 1334156248 695 D0
/
213 DATA W87A
( 7) / 0.0136859460 2271270188 8950035273 128 D0
/
214 DATA W87A
( 8) / 0.0232804135 0288831112 3409291030 404 D0
/
215 DATA W87A
( 9) / 0.0308724976 1171335867 5466394126 442 D0
/
216 DATA W87A
( 10) / 0.0356936336 3941877071 9351355457 044 D0
/
217 DATA W87A
( 11) / 0.0009152833 4520224136 0843392549 948 D0
/
218 DATA W87A
( 12) / 0.0053992802 1930047136 7738743391 053 D0
/
219 DATA W87A
( 13) / 0.0109476796 0111893113 4327826856 808 D0
/
220 DATA W87A
( 14) / 0.0162987316 9678733526 2665703223 280 D0
/
221 DATA W87A
( 15) / 0.0210815688 8920383511 2433060188 190 D0
/
222 DATA W87A
( 16) / 0.0253709697 6925382724 3467999831 710 D0
/
223 DATA W87A
( 17) / 0.0291896977 5647575250 1446154084 920 D0
/
224 DATA W87A
( 18) / 0.0323732024 6720278968 5788194889 595 D0
/
225 DATA W87A
( 19) / 0.0347830989 5036514275 0781997949 596 D0
/
226 DATA W87A
( 20) / 0.0364122207 3135178756 2801163687 577 D0
/
227 DATA W87A
( 21) / 0.0372538755 0304770853 9592001191 226 D0
/
228 DATA W87B
( 1) / 0.0002741455 6376207235 0016527092 881 D0
/
229 DATA W87B
( 2) / 0.0018071241 5505794294 8341311753 254 D0
/
230 DATA W87B
( 3) / 0.0040968692 8275916486 4458070683 480 D0
/
231 DATA W87B
( 4) / 0.0067582900 5184737869 9816577897 424 D0
/
232 DATA W87B
( 5) / 0.0095499576 7220164653 6053581325 377 D0
/
233 DATA W87B
( 6) / 0.0123294476 5224485369 4626639963 780 D0
/
234 DATA W87B
( 7) / 0.0150104473 4638895237 6697286041 943 D0
/
235 DATA W87B
( 8) / 0.0175489679 8624319109 9665352925 900 D0
/
236 DATA W87B
( 9) / 0.0199380377 8644088820 2278192730 714 D0
/
237 DATA W87B
( 10) / 0.0221949359 6101228679 6332102959 499 D0
/
238 DATA W87B
( 11) / 0.0243391471 2600080547 0360647041 454 D0
/
239 DATA W87B
( 12) / 0.0263745054 1483920724 1503786552 615 D0
/
240 DATA W87B
( 13) / 0.0282869107 8877120065 9968002987 960 D0
/
241 DATA W87B
( 14) / 0.0300525811 2809269532 2521110347 341 D0
/
242 DATA W87B
( 15) / 0.0316467513 7143992940 4586051078 883 D0
/
243 DATA W87B
( 16) / 0.0330504134 1997850329 0785944862 689 D0
/
244 DATA W87B
( 17) / 0.0342550997 0422606178 7082821046 821 D0
/
245 DATA W87B
( 18) / 0.0352624126 6015668103 3782717998 428 D0
/
246 DATA W87B
( 19) / 0.0360769896 2288870118 5500318003 895 D0
/
247 DATA W87B
( 20) / 0.0366986044 9845609449 8018047441 094 D0
/
248 DATA W87B
( 21) / 0.0371205492 6983257611 4119958413 599 D0
/
249 DATA W87B
( 22) / 0.0373342287 5193504032 1235449094 698 D0
/
250 DATA W87B
( 23) / 0.0373610737 6267902341 0321241766 599 D0
/
252 C LIST OF MAJOR VARIABLES
253 C -----------------------
255 C CENTR - MID POINT OF THE INTEGRATION INTERVAL
256 C HLGTH - HALF-LENGTH OF THE INTEGRATION INTERVAL
257 C FCENTR - FUNCTION VALUE AT MID POINT
259 C FVAL - FUNCTION VALUE
260 C SAVFUN - ARRAY OF FUNCTION VALUES WHICH HAVE ALREADY BEEN
262 C RES10 - 10-POINT GAUSS RESULT
263 C RES21 - 21-POINT KRONROD RESULT
264 C RES43 - 43-POINT RESULT
265 C RES87 - 87-POINT RESULT
266 C RESABS - APPROXIMATION TO THE INTEGRAL OF ABS(F)
267 C RESASC - APPROXIMATION TO THE INTEGRAL OF ABS(F-I/(B-A))
269 C MACHINE DEPENDENT CONSTANTS
270 C ---------------------------
272 C EPMACH IS THE LARGEST RELATIVE SPACING.
273 C UFLOW IS THE SMALLEST POSITIVE MAGNITUDE.
275 C***FIRST EXECUTABLE STATEMENT DQNG
279 C TEST ON VALIDITY OF PARAMETERS
280 C ------------------------------
286 IF(EPSABS
.LE
.0.0D
+00.AND
.EPSREL
.LT
.MAX
(0.5D
+02*EPMACH
,0.5D
-28))
288 HLGTH
= 0.5D
+00*(B
-A
)
290 CENTR
= 0.5D
+00*(B
+A
)
295 C COMPUTE THE INTEGRAL USING THE 10- AND 21-POINT FORMULA.
300 RES21
= W21B
(6)*FCENTR
301 RESABS
= W21B
(6)*ABS
(FCENTR
)
304 FVAL1
= F
(CENTR
+ABSC
)
305 FVAL2
= F
(CENTR
-ABSC
)
307 RES10
= RES10
+W10
(K
)*FVAL
308 RES21
= RES21
+W21A
(K
)*FVAL
309 RESABS
= RESABS
+W21A
(K
)*(ABS
(FVAL1
)+ABS
(FVAL2
))
318 FVAL1
= F
(CENTR
+ABSC
)
319 FVAL2
= F
(CENTR
-ABSC
)
321 RES21
= RES21
+W21B
(K
)*FVAL
322 RESABS
= RESABS
+W21B
(K
)*(ABS
(FVAL1
)+ABS
(FVAL2
))
328 C TEST FOR CONVERGENCE.
331 RESABS
= RESABS*DHLGTH
332 RESKH
= 0.5D
+00*RES21
333 RESASC
= W21B
(6)*ABS
(FCENTR
-RESKH
)
335 RESASC
= RESASC
+W21A
(K
)*(ABS
(FV1
(K
)-RESKH
)+ABS
(FV2
(K
)-RESKH
))
336 1 +W21B
(K
)*(ABS
(FV3
(K
)-RESKH
)+ABS
(FV4
(K
)-RESKH
))
338 ABSERR
= ABS
((RES21
-RES10
)*HLGTH
)
339 RESASC
= RESASC*DHLGTH
342 C COMPUTE THE INTEGRAL USING THE 43-POINT FORMULA.
344 25 RES43
= W43B
(12)*FCENTR
347 RES43
= RES43
+SAVFUN
(K
)*W43A
(K
)
352 FVAL
= F
(ABSC
+CENTR
)+F
(CENTR
-ABSC
)
353 RES43
= RES43
+FVAL*W43B
(K
)
357 C TEST FOR CONVERGENCE.
360 ABSERR
= ABS
((RES43
-RES21
)*HLGTH
)
363 C COMPUTE THE INTEGRAL USING THE 87-POINT FORMULA.
365 45 RES87
= W87B
(23)*FCENTR
368 RES87
= RES87
+SAVFUN
(K
)*W87A
(K
)
372 RES87
= RES87
+W87B
(K
)*(F
(ABSC
+CENTR
)+F
(CENTR
-ABSC
))
375 ABSERR
= ABS
((RES87
-RES43
)*HLGTH
)
376 65 IF(RESASC
.NE
.0.0D
+00.AND
.ABSERR
.NE
.0.0D
+00)
377 1 ABSERR
= RESASC*MIN
(0.1D
+01,(0.2D
+03*ABSERR
/RESASC
)**1.5D
+00)
378 IF (RESABS
.GT
.UFLOW
/(0.5D
+02*EPMACH
)) ABSERR
= MAX
379 1 ((EPMACH*0
.5D
+02)*RESABS
,ABSERR
)
380 IF (ABSERR
.LE
.MAX
(EPSABS
,EPSREL*ABS
(RESULT
))) IER
= 0
381 C ***JUMP OUT OF DO-LOOP
382 IF (IER
.EQ
.0) GO TO 999
384 80 CALL XERMSG
('SLATEC', 'DQNG', 'ABNORMAL RETURN', IER
, 0)