Skip to content

Take a rational integral down to -oo as its reflection up to +oo (#2646) - #2647

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
reflect-minus-infinity-2646
Nov 29, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
reflect-minus-infinity-2646

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

An antiderivative's sum over roots is taken at +oo through Euler–Jacobi (#2630, #2636), but at -oo each ln(x - r) approaches the logarithm's cut from a side that depends on the sign of Im r. For a real root computed to a hundred digits, that sign is not decided. So a rational integral down to -oo, or over the whole line, was left unevaluated wherever its antiderivative has a root sum. 2.10.0 answered NaN.

The integral of f over (-oo, b] equals the integral of f(-t) over [-b, +oo) exactly, so no branch question arises. Over the whole line the integral is split at 0. This is 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 a polynomial.

I used the reflection instead of the per-root branch formula θ_r = π(1 − sgn Im r − |sgn Im r|) that I had proposed. That formula needs the sign of Im r for every root, and a numerically computed real root can carry an imaginary part of ±1e-100. Getting that sign wrong for a real root would put a spurious ±π c(r) i into the answer. The reflection never asks for that sign.

simplified 2.10.0 master this branch mpmath
integral(1/(x^3 + 3x - 1), x, -oo, -1) NaN unevaluated root sum -0.210069487870138069…
integral((x - 2)/(x^4 + 3x + 1), x, -oo, -2) — unevaluated root sum -0.245750699454190650…
integral(1/(x^3 + x + 1), x, -oo, -1) NaN unevaluated root sum -0.455282857458523731…
integral(1/(x^4 + x + 1), x, -oo, +oo) NaN unevaluated root sum 2.683548244256476479…
integral(1/(x^3 + x + 1), x, -oo, +oo) — unevaluated unevaluated (a pole on the line) —

Checks

  • Sweep: 140 random rational integrands of degree 3–7 with sign-varied coefficients over infinite ranges, checked against mpmath at 50 digits. 139 are answered (49 on master before A root sum beside a separate logarithm is left unevaluated at +oo: integral((x+2)/(x^4-2x^3-2x+3), x, 3, +oo) #2636, 63 after), 1 is unevaluated, and 0 are wrong.
  • Diff against master: 223 definite integrals. Only 1/(x^3+x+1) over (-oo, -1] changed, and it now matches mpmath.
  • New test: 8 cases.
  • Full UnitTests suite: 21853 passed, 0 failed, 13 skipped (net10.0).
  • Build: 0 errors on every target framework.

Closes #2646.

🤖 Generated with Claude Code

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]>
@codecov

codecov Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.71%. Comparing base (dccddc5) to head (90ef895).

Files with missing lines Patch % Lines
...s/Continuous/Integration/Integration.Definition.cs 92.30% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2647   +/-   ##
=======================================
  Coverage   86.71%   86.71%           
=======================================
  Files         346      346           
  Lines       75647    75660   +13     
  Branches    22114    22118    +4     
=======================================
+ Hits        65596    65610   +14     
+ Misses       5420     5418    -2     
- Partials     4631     4632    +1     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.21% <92.30%> (+<0.01%) ⬆️
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 Δ
...s/Continuous/Integration/Integration.Definition.cs 86.46% <92.30%> (+0.09%) ⬆️

... and 4 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 ad57ae3 into master Nov 29, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Nov 29, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the reflect-minus-infinity-2646 branch November 29, 2026 04:16
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.

A rational integral with a root-sum antiderivative is left unevaluated down to -oo

1 participant