Skip to content

Count the jump where a definite integral crosses a branch cut off the real line, and take each case of a piecewise antiderivative across the range - #2465

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
fix/antiderivative-breaks
Nov 15, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
fix/antiderivative-breaks

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Two commits, one per issue, meant to be merged as they are (rebase, not squash). Both are about where a definite integral's antiderivative breaks inside the range.

Branch cuts crossed off the real line (#2460)

The breaks of an antiderivative were looked for on the real line with the parameters read as real, so a jump that comes from a complex shift was not counted, and the answer was off by a multiple of π. AntiderivativeBreaks.CutCrossings now places the crossings of arctan's cut (the imaginary axis beyond ±i) and the logarithm's (the negative real axis) for a polynomial argument with numeric complex coefficients, and of ln(cos(a t + b)) and ln(sin(a t + b)) with numeric complex a, b (what tan and cot integrate to: the argument is p + i q with both linear in t, real where sin p = 0 or q = 0). The jump at each is the node's coefficient times a whole multiple of π, or of 2πi/ln(base), read numerically either side of the crossing and required to be whole within 1e-6.

input 2.7.0 now quadrature
1/(1+(t-3i)^2), [−2, 2] 2.8198 −0.32175 −0.32175
same, (−∞, ∞) pi 0 0
1/(1+(t-3i)^2), [0, ∞) 3.1416 + 0.3466i 0.3466i 0.3466i
1/((1+i)t-5-3i), [0, 5] 1.5510 + 2.6210i −1.5906 − 0.5206i same
t/(1+(t-3i)^2), [−2, 2] 6.5670i 0.2838i same
tan(t+i), [0, 4] 0.1376 − 2.4189i 0.1376 + 3.8643i same
tan((1+i)t), [0, 4] −2.7951 + 0.5116i 0.3464 + 3.6532i same
tan((2-i)t+1/2), [0, 2] −0.9264 + 0.4322i 0.3302 − 2.0811i same
sqrt((1+i)t-5-3i), [0, 5] 0.1675 − 5.3020i not answered 2.0531 − 3.4186i
1/(1+(t-i)^2), [−1, 1] 2.0344 not answered diverges
1/(1+(t-i/2)^2), (−∞, ∞) pi unchanged π

Every row checked against mpmath quadrature at 30 digits; real shifts are unchanged. Not answered, as before or newly: a non-integer power whose base crosses its cut inside the range (its jump is not a constant), a crossing with a symbolic bound or a symbol beside the complex constant, a crossing that coincides with a real break or sits at the end of a cut, a zero on the path, and any other function whose argument leaves the real line, apart from a list that is safe off it.

For a symbolic shift, integral(1/(1+(t-y)^2), t, -oo, +oo) stays pi, which is right for |Im y| < 1. The rest of integration reads a bare symbol as real (the break search, the case splits on y^2), and no parametric definite answer carries y in RR; adding it would make the answer NaN, "does not exist", at y = i/2, where pi is right.

Each case of a piecewise antiderivative across the range (#2461)

The antiderivative of 1/(t^2+y^2) is a piecewise on y. Its breaks were read for the whole piecewise, the y^2 < 0 case's could not be listed, and the integral fell back to substituting the bounds, so the y = 0 case's pole at 0 (-1/t) was never looked for. A piecewise antiderivative whose conditions do not mention the variable is now taken across the range case by case, each with its own breaks, which covers any special case that puts a pole in range. Divergence is written as the library writes integral(1/t^2, t, -1, 1), +oo.

y = 0 case of 2.7.0 now
1/(t^2+y^2), [−1, 1] (-2) provided (y = 0) +oo provided (y = 0)
same, (−∞, ∞) 0 provided (y = 0) +oo provided (y = 0)
same, [1, 2] 1/2 unchanged

Real y ≠ 0 is unchanged, checked against 2·arctan(1/|y|)/|y|.

Checks

IntegralAcrossABreakTest: Issue2460_* (24 + 4 rows), Issue2461_* (4 + 3). Calculus|Integra|Limit: 7139 → 7173 passed. Full check on the branch before the rebase onto 5ba95bc (clean): 20,052 unit tests, 0 failed; MCP 444, Terminal 69, F# 134, Interactive 19; AOT OK; BoundCheck 0 disagreements, RootCheck 596/596, CasBench 120/121 with 0 wrong, PropCheck 1355/0, SimpSweep 10463/10463, RuleCheck clean, CanonCheck and Confluence at their baselines. After the rebase (master gained #2463 and #2464, which changed DomainCondition), Calculus|Integra|Limit|Binder|FreeVariables|Domain: 8,320 passed, 0 failed.

Closes #2460.
Closes #2461.

🤖 Generated with Claude Code

Rafael-SOWNet and others added 2 commits November 15, 2026 22:25
…ranch cut off the real line

The breaks of an antiderivative were looked for on the real line, where arctan and
the logarithm of a real argument have no cut to cross. A complex constant takes the
argument off the line: arctan(t - 3i) meets arctan's cut at -3i and jumps by pi, so
the integral of 1/(1 + (t - 3i)^2) over [-2, 2] was 2.8198 where it is -0.3218, and
over the line pi where it is 0.

The crossings of arctan's cut and the logarithm's are now placed for a polynomial
argument with numeric coefficients, and for the logarithm of the cosine or the sine
of a linear argument with numeric coefficients, which tan and cot integrate to: the
cosine of p + i q is real where sin p = 0 or q = 0, a periodic set and a single
point of t, and so is the sine where cos p = 0 or q = 0. Each jump is
a whole multiple of pi or 2 pi i / ln(base), read from the values either side, and
is counted with the node's coefficient; a bound on the cut takes the value from
inside the range. Where a crossing cannot be placed or its jump is not a constant --
a power whose base crosses the negative real axis, a bound that is not a number, a
symbol beside the complex constant, any other argument off the line -- the integral
is left as written.

A symbol is still read as real, as everywhere the breaks are read, so
integral(1/(1+(t-y)^2), t, -oo, +oo) stays pi.

Part of #2460

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ve splits on a parameter

The antiderivative of 1/(t^2 + y^2) is a case split on y, and its case y = 0, -1/t,
has a pole at 0. The breaks were looked for in the whole split, where the logarithm
of the case y^2 < 0 cannot be listed, so none were looked for at all and the case
y = 0 answered -1/t at the bounds: -2 over [-1, 1], 0 over the line, for a positive
integrand whose integral diverges.

A piecewise antiderivative whose conditions do not mention the variable is now taken
across the range case by case, each with its own breaks, and the case y = 0 is +oo,
as the integral of 1/t^2 over [-1, 1] is. The other cases are as they were.

Part of #2461

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.84971% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.94%. Comparing base (5ba95bc) to head (1d7d36e).

Files with missing lines Patch % Lines
...ons/Continuous/Integration/AntiderivativeBreaks.cs 60.83% 25 Missing and 22 partials ⚠️
...s/Continuous/Integration/Integration.Definition.cs 64.15% 10 Missing and 9 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2465      +/-   ##
==========================================
- Coverage   87.01%   86.94%   -0.08%     
==========================================
  Files         320      320              
  Lines       71232    71398     +166     
  Branches    20775    20847      +72     
==========================================
+ Hits        61985    62076      +91     
- Misses       4961     5006      +45     
- Partials     4286     4316      +30     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.47% <61.84%> (-0.08%) ⬇️
fsharp 32.97% <ø> (ø)
interactive 39.81% <ø> (ø)

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 88.43% <64.15%> (-2.31%) ⬇️
...ons/Continuous/Integration/AntiderivativeBreaks.cs 63.91% <60.83%> (-0.95%) ⬇️

... and 7 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 dd5cc83 into master Nov 15, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Nov 15, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the fix/antiderivative-breaks branch November 15, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

1 participant