Skip to content

Take a sum over roots to 0 at +oo, and break it at a real root (#2624) - #2630

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
rootsum-limit-2624
Nov 28, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
rootsum-limit-2624

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Two wrong answers came from the root-sum antiderivative sum(c(r) ln(x - r), r in { r : p(r) = 0 }):

  • At an infinite bound: the sum was substituted with +oo inside. That evaluates to NaN, so integral(1/(x^3+x+1), x, 0, +oo) simplified to NaN.
  • Across a real root: the sum was taken as if it were continuous. Its breaks were never listed, because ln(x - r) holds the bound variable r. So integral(1/(x^3+x+1), x, -1, 0), which diverges at the root -0.6823…, came out as a complex number.

Fix

  • At +oo: sum c(r) ln(x - r) = (sum c(r)) ln(x) + sum c(r) ln(1 - r/x). The second part tends to 0.
    • Where p is square-free and c(r) p'(r) is a polynomial of degree at most deg p - 2, the Euler–Jacobi identity makes sum c(r) = 0 exactly. The root sum is then 0 at the bound.
    • That degree condition is exactly what convergence at +oo requires of a rational integrand.
    • Otherwise the bound has no value: the integral is left unevaluated, never NaN.
  • At -oo: the bound has no value, since ln(x - r) takes a branch that depends on each root.
  • Breaks (AntiderivativeBreaks.Inside): a root sum now breaks at the real zeros of its polynomial in x, so a real root inside the range is no longer jumped over.
simplified master / 2.10.0 this branch mpmath
integral(1/(x^3+x+1), x, 0, +oo) NaN -sum(ln(-r) / (1 + 3 r^2), r…) 0.921763372185058
integral(1/(x^3-x^2+1), x, 0, +oo) NaN root sum 1.79044536812823
integral(1/(x^5+x+1), x, 0, +oo) NaN root sum 0.795904895024779
integral(1/(x^5+x+1), x, 1, +oo) — root sum 0.142012887209207
integral(x/(x^3+x+1), x, 0, +oo) — root sum 0.96934396330681
integral(1/(x^5+3x+5), x, 0, +oo) — root sum 0.229150744145838
integral(1/(x^3+x+1), x, -1, 0) a complex number unevaluated (diverges) —
integral(1/(x^3+x+1), x, -oo, 0) NaN unevaluated —
integral(x^2/(x^3+x+1), x, 0, +oo) NaN unevaluated (diverges) —

Checks

  • Quadrature. Every value agrees with mpmath to 1e-12. The roots involved are negative real and complex-conjugate pairs.
  • Regression diff. 186 definite integrals were diffed against master. The only changed row is 1/(x^5+x+1) over [0, +oo).
  • New test. It fails all 12 of its cases on master.
  • Build. The library builds with 0 errors for every target framework.
  • Full suite. It runs under the lock; the result is posted on this PR once it is in.

This touches Integration.Definition.cs, the same file as #2626, but in AtTheBound and a new function, not in WithItsLogarithmsGathered. The BREAKING-CHANGES.md entry sits where #2626's ends, so one of the two will need a mechanical merge round.

Closes #2624.

🤖 Generated with Claude Code

The antiderivative of 1/(x^3 + x + 1) is sum(ln(x - r) / (3 r^2 + 1), r)
over the roots of r^3 + r + 1. At an infinite bound it was substituted
and left with +oo inside. Nothing settles that sum, and it evaluates to
NaN, so the integral over [0, +oo) simplified to NaN where it is
0.92176. Its breaks were never listed either: ln(x - r) holds the bound
r, whose zeros the solver cannot place. So over [-1, 0] the root sum was
taken across the real root -0.6823 as if it were continuous, and the
divergent integral came out as a complex number.

At +oo, a root sum sum(c(r) ln(x - r)) is (sum c(r)) ln(x) plus terms
that tend to 0. Where c(r) p'(r) is a polynomial of degree at most
deg p - 2 and p is square-free, the Euler-Jacobi identity makes sum c(r)
exactly 0, and the root sum is 0 at the bound. This is the condition for
convergence of a rational integrand at +oo. A root sum not shown to
vanish, and any root sum at -oo, leaves the bound with no value instead
of NaN. The breaks of a root sum are now the real zeros of its
polynomial in x. A real root inside the range therefore leaves the
integral unevaluated unless the one-sided limits settle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Rafael-SOWNet

Copy link
Copy Markdown
Member Author

Full unit suite on b3f5daf (master fc8aaf4 + this): Passed 21761, Failed 0, Skipped 13. The cross-check chain is queued.

@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.74510% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.70%. Comparing base (05708b6) to head (11a2b93).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...s/Continuous/Integration/Integration.Definition.cs 60.97% 7 Missing and 9 partials ⚠️
...ons/Continuous/Integration/AntiderivativeBreaks.cs 70.00% 1 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2630      +/-   ##
==========================================
- Coverage   86.71%   86.70%   -0.02%     
==========================================
  Files         345      345              
  Lines       75396    75447      +51     
  Branches    22036    22057      +21     
==========================================
+ Hits        65377    65413      +36     
- Misses       5409     5413       +4     
- Partials     4610     4621      +11     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.20% <62.74%> (-0.02%) ⬇️
fsharp 32.79% <ø> (ø)
interactive 40.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ons/Continuous/Integration/AntiderivativeBreaks.cs 58.99% <70.00%> (+0.48%) ⬆️
...s/Continuous/Integration/Integration.Definition.cs 86.65% <60.97%> (-1.12%) ⬇️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rafael-SOWNet
Rafael-SOWNet merged commit a3b3d25 into master Nov 28, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Nov 28, 2026
@Rafael-SOWNet

Copy link
Copy Markdown
Member Author

Note: the squash commit a3b3d25 on master went in with the wrong subject line. It repeats #2626's. The subject should read "Take a sum over roots to 0 at +oo, and break it at a real root (#2630)". The body and the diff are this PR's, as intended. The full suite passed (21796) on master merged with #2631, #2629 and this PR.

@Rafael-SOWNet
Rafael-SOWNet deleted the rootsum-limit-2624 branch November 28, 2026 21:00
Rafael-SOWNet added a commit that referenced this pull request Nov 29, 2026
)

A sum over roots sum(c(r) ln(x - r)) is (sum c(r)) ln(x) plus terms that
tend to 0 at +oo. #2630 took it at +oo only where sum c(r) is 0 on its
own. The antiderivative of (x + 2)/(x^4 - 2x^3 - 2x + 3) is
-3/4 ln(x - 1) beside a sum with sum c(r) = 3/4. The two cancel only
together, and the integral over [3, +oo) was left unevaluated.

By the Euler-Jacobi identity, sum c(r) is exactly the coefficient of
r^(n - 1) in c(r) p'(r) over p's leading coefficient. Each sum now
stands at the bound as that multiple of ln(x), which differs from it by
terms that tend to 0, so the gathering of logarithms cancels it with the
others. Where nothing cancels the integral diverges, and it is now +oo.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rafael-SOWNet added a commit that referenced this pull request Nov 29, 2026
…) (#2647)

An antiderivative's sum over roots is taken at +oo (#2630, #2636) but
not at -oo, where each ln(x - r) nears the logarithm's cut from a side
that depends on the sign of Im r. A root computed to a hundred digits
does not decide that sign for a real root. So 1/(x^3 + 3x - 1) over
(-oo, -1] was left unevaluated while its mirror over [1, +oo) was
answered, and 2.10.0 answered it NaN.

The integral of f over (-oo, b] equals the integral of f(-t) over
[-b, +oo) exactly, and over the whole line the integral is the two
halves split at 0. That is now the last route tried for a lower bound
at -oo, after every other route has declined. The reflected integrand
is simplified first, so that (-x)^3 reads as the polynomial -x^3. A
pole on the line still leaves no finite value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

An integral over [0, +oo) whose antiderivative is a root sum simplifies to NaN: integral(1/(x^3+x+1), x, 0, +oo)

1 participant