Repository navigation
Take a sign at a definite integral's bound from inside the range - #2731
Open
Rafael-SOWNet wants to merge 1 commit into
Open
Rafael-SOWNet wants to merge 1 commit into
Rafael-SOWNet wants to merge 1 commit into
Conversation
An antiderivative holding sgn(u), which the integrator writes for sgn and abs of u, was taken at a bound by substitution. Where u is zero at the bound, sgn(u) there is 0, while the integral takes the antiderivative's limit from inside the range, where sgn(u) is the sign of u next to the bound. So exp(x) sgn(x) over [0, 1/2] was sqrt(e) where it is sqrt(e) - 1, abs(ln(x)) over [1, 2] was negative, and exp(-x) abs(sin(x)) over [0, pi] was 0. Interior breaks were already taken by one-sided limits. Where the antiderivative's breaks in the range are listed, the sign of u is constant between a bound and the nearest break, since the zeros of u are among the breaks. Each sgn(u) whose value at the bound differs from the sign of u at the midpoint of that stretch is replaced by that sign before the bound is taken. This is exact, and it changes nothing where u is not zero at the bound. Where the breaks could not be listed and a sgn(u) has zeros of a kind that is listed, there were too many in the range or infinitely many, and the antiderivative jumps at them uncounted: exp(-x) abs(sin(x)) over [0, +oo) was 0. Such an integral is now left unevaluated. A sign whose zeros are of no listed kind keeps the old path, because the integrator writes it beside a factor that makes the antiderivative continuous, as in arctan(tan(x^2/2)) sgn(sin(x^2)) for x sgn(sin(x^2)). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2731 +/- ##
==========================================
+ Coverage 86.65% 86.68% +0.03%
==========================================
Files 346 346
Lines 76959 76993 +34
Branches 22644 22653 +9
==========================================
+ Hits 66692 66745 +53
+ Misses 5534 5521 -13
+ Partials 4733 4727 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A definite integral through an antiderivative that holds
sgn(u)took the antiderivative at a bound by substitution. Whereuis zero at the bound,sgn(u)is 0 there, but the integral needs the limit from inside the range. That limit is the sign ofunext to the bound.What changed
sgn(u)that disagrees at a bound with the sign ofuat the midpoint between that bound and the nearest break is replaced by that sign before the bound is taken. This is exact: the zeros ofuare among the breaks. Nothing changes whereuis not zero at the bound.sgn(u)has zeros of a kind that is listed, there are too many of them or infinitely many, and the old answer skipped those jumps. Such an integral is now left unevaluated, for exampleexp(-x) abs(sin(x))over[0, +oo), which was0. A sign whose zeros are of no listed kind keeps the old path.x sgn(sin(x^2))integrates to a continuousarctan(tan(x^2/2)) sgn(...), and its answers stay right.Measured against mpmath
quadat 50 digits, with the probe built on master 409d688 and on this branch. 15 of the sweep's 16 group-A rows are in the 68 rows checked, plus variants. The 16th,abs(x - 1/2) Chi(-x)over[-1, 1], is the same on master and this branch. Its real part is right; its imaginary part ispi/8where mpmath givespi/4. That isChiof a negative argument, with no sign at a bound, so it is outside this fix. One row,sgn(sin(x)) e^(-x)over[0, 100], was checked against the exact sum over its 31 sign intervals, becausequadwas off by 4e-12 there. The variants cover zero at the upper bound, at both bounds, reversed bounds, infinite bounds, andsgn/absof polynomials, trig,ln,erf,SiandShiintegrands.abs(sin),abs(cos)timese^(-x)over[0, +oo);sgn(sin(x)) e^(-x)over[0, 300], 95 zeros)A few rows of the issue:
simplify(integral(…))exp(x) sgn(x), x, 0, 1/2sqrt(e)sqrt(e) - 1abs(ln(x)), x, 1, 22 ln(2) - 22 ln(2) - 1sgn(1 - x^2) x^2, x, 0, 101/3exp(-x) abs(sin(x)), x, 0, pi0(1 + e^(-pi))/2sgn(sin(x)) cosh(x), x, 0, 2 pie^pi - e^(-pi)2 sinh(pi) - sinh(2 pi)= -244.647Si(x) sgn(1 - x), x, -1, 1Si(-1) - cos(-1)0Unit suite: 22337 passed, 0 failed. CasBench: 120/121, 0 wrong, same as master. PropCheck: 1355 checks, 0 failures, same as master. Probe timings are unchanged, except for two rows that went from wrong to right (about +100 ms each). 2.10.0 gives the same wrong values as master, so there is an entry in BREAKING-CHANGES.md.
The
lnof a negative argument (#2715) is not touched.Fixes #2714
🤖 Generated with Claude Code