Commit febd4e2
committed
FIX: Correct Gauss sum for even-order Gauss-Kronrod rules (#93)
The evaluation-reusing path (compute_gauss_kronrod_sums_stored,
introduced in faeaf2b) reconstructed the Gauss sum assuming an
odd-order Gauss rule: a center node at 0.0 plus pairs at Kronrod
offsets +/- 2j. Even-order rules (G10/G20/G30) have no node at 0.0;
their nodes sit at odd Kronrod offsets +/- (2j - 1). The old code
therefore added a spurious center term (a Kronrod-only node times an
ordinary pair weight), dropped one node pair, and read every pair
from Kronrod-only nodes, so the "Gauss" sum contained no Gauss node
at all. |G - K| then decayed only linearly with interval width, so
G10K21 / G20K41 / G30K61 (and R variants) never early-exited and
always subdivided to max_iter, even for a constant integrand.
Branch on the parity of g: odd keeps the previous mapping, even skips
the center term, sums all g/2 pairs at offsets +/- (2j - 1), and
starts pair weights at index g/2 - 1.
Tests:
* unit: reconstructed G matches direct Gauss-Legendre and |G - K| is
round-off for a cubic, for all six rules (failed on G10K21 before)
* integration: a cubic finishes in exactly k evaluations for all
twelve method variants, and the optimized path agrees with the
reference gauss_kronrod_quadrature on a generic smooth integrand1 parent 087fd4f commit febd4e2
2 files changed
Lines changed: 139 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
503 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
504 | 507 | | |
505 | | - | |
506 | | - | |
507 | 508 | | |
508 | | - | |
509 | | - | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
510 | 526 | | |
511 | 527 | | |
512 | 528 | | |
513 | | - | |
| 529 | + | |
| 530 | + | |
514 | 531 | | |
515 | 532 | | |
516 | 533 | | |
517 | 534 | | |
518 | 535 | | |
519 | 536 | | |
520 | | - | |
521 | | - | |
522 | | - | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
523 | 540 | | |
524 | 541 | | |
525 | | - | |
| 542 | + | |
526 | 543 | | |
527 | 544 | | |
528 | 545 | | |
| |||
2192 | 2209 | | |
2193 | 2210 | | |
2194 | 2211 | | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
98 | 157 | | |
99 | 158 | | |
100 | 159 | | |
| |||
0 commit comments