Commit f941978
PolynomialGcd.Gcd declined on inputs well inside every documented limit, because an
intermediate of the subresultant remainder sequence went past MultivariatePolynomial.MaxTerms
while neither input nor answer came close:
left (b + c + 1) * (a + b) * (a + b + c + d) 19 terms
right (a^2 + b*c + d) * (a + b + c + d) * (a + b + c + d) 29 terms
gcd a + b + c + d 4 terms was declined
A multivariate pseudo-remainder multiplies through by a leading coefficient that is itself a
polynomial. The subresultant divisions bound how large the coefficients get -- which is what
the class remark is about, and it holds -- but nothing bounds the monomial count, and three
steps in a 25-term lead times a 159-term remainder passes 512.
Raising MaxTerms is the one-line version and it is the wrong shape, which the measurement
shows rather than the reasoning: at 2048 three documented refusals become answers, including
TermCountsPastTheCeilingAreRefused, whose subject is a direct product of two 495-term inputs,
and RefusedRatherThanAnsweredWrongly, whose input has 1001 terms and is meant to be stopped at
the door. The bound on what may be *asked* was never too small. What was too small was the
bound on what may be passed through on the way to an answer that is itself small.
So MaxIntermediateTerms is a second constant, 4096, threaded as an optional argument through
Multiply, Power and DivideExact and passed only by the gcd's remainder sequence. Everything
reached any other way keeps MaxTerms by default, so the entry bound that protects the hot path
is untouched and all three of those refusals still refuse.
3000 drawn triples 7 declined -> 0 declined
the pair above declined -> a + b + c + d, checked as a greatest common divisor
The sweep now asserts the count is zero rather than at most seven, so a refusal coming back
fails there instead of passing quietly under a ceiling.
Performance, which is the part #920 asked not be guessed at: TryCancel runs on every quotient
the simplifier builds, so simpsweep is the hot path. Two runs at 4096 took 3m26.8s and 3m40.7s,
one at 512 took 3m45.3s. The spread between repeats of the same setting is as large as the gap
between the settings, so this supports no regression and does not support a speedup. The gcd
test class is unchanged at 1 s.
Verified: 6944 C# tests and 130 F# tests pass, 0 fail. propcheck 1340 checks 0 failures,
simpsweep 10463/10463 agree 0 disagreements, rootcheck 596/596 clean, casbench 117/119 with
0 wrong, 0 error and 0 timeout.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 9d37492 commit f941978
3 files changed
Lines changed: 58 additions & 28 deletions
File tree
- Sources
- AngouriMath/Functions/Algebra/Polynomials
- Tests/UnitTests/Algebra/Polynomials
Lines changed: 29 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
66 | 87 | | |
67 | 88 | | |
68 | 89 | | |
| |||
163 | 184 | | |
164 | 185 | | |
165 | 186 | | |
166 | | - | |
| 187 | + | |
167 | 188 | | |
168 | 189 | | |
169 | 190 | | |
| |||
174 | 195 | | |
175 | 196 | | |
176 | 197 | | |
177 | | - | |
| 198 | + | |
178 | 199 | | |
179 | 200 | | |
180 | 201 | | |
181 | 202 | | |
182 | 203 | | |
183 | | - | |
| 204 | + | |
184 | 205 | | |
185 | 206 | | |
186 | 207 | | |
| |||
190 | 211 | | |
191 | 212 | | |
192 | 213 | | |
193 | | - | |
| 214 | + | |
194 | 215 | | |
195 | 216 | | |
196 | 217 | | |
197 | 218 | | |
198 | 219 | | |
199 | 220 | | |
200 | | - | |
| 221 | + | |
201 | 222 | | |
202 | 223 | | |
203 | 224 | | |
| |||
292 | 313 | | |
293 | 314 | | |
294 | 315 | | |
295 | | - | |
| 316 | + | |
296 | 317 | | |
297 | 318 | | |
298 | 319 | | |
| |||
305 | 326 | | |
306 | 327 | | |
307 | 328 | | |
308 | | - | |
| 329 | + | |
309 | 330 | | |
310 | 331 | | |
311 | 332 | | |
| |||
317 | 338 | | |
318 | 339 | | |
319 | 340 | | |
320 | | - | |
| 341 | + | |
321 | 342 | | |
322 | 343 | | |
323 | 344 | | |
| |||
Lines changed: 9 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | | - | |
244 | | - | |
245 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
256 | | - | |
257 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
285 | | - | |
| 284 | + | |
| 285 | + | |
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
| 295 | + | |
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| |||
Lines changed: 20 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
302 | 305 | | |
303 | 306 | | |
304 | 307 | | |
| |||
322 | 325 | | |
323 | 326 | | |
324 | 327 | | |
325 | | - | |
| 328 | + | |
326 | 329 | | |
327 | 330 | | |
328 | 331 | | |
| |||
501 | 504 | | |
502 | 505 | | |
503 | 506 | | |
504 | | - | |
505 | | - | |
506 | | - | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
507 | 512 | | |
508 | 513 | | |
509 | | - | |
| 514 | + | |
510 | 515 | | |
511 | 516 | | |
512 | 517 | | |
513 | 518 | | |
514 | 519 | | |
515 | 520 | | |
516 | 521 | | |
517 | | - | |
| 522 | + | |
518 | 523 | | |
519 | 524 | | |
520 | 525 | | |
521 | | - | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
522 | 531 | | |
523 | 532 | | |
524 | 533 | | |
| |||
0 commit comments