Repository navigation
Read a limit that is 0 written another way as 0 (#2639) - #2655
Merged
Merged
Conversation
#2632 reads a limit that comes back as a constant minus itself as 0. A zero written any other way was still kept as a nonzero constant: the limit of tan(a + x) - tan(a) at 0 comes back sin(a) / cos(a) - tan(a), one step of l'Hopital's rule on (cosh(a x) - 1) / x^2 leaves 1/2 a + -1/2 a, and the difference quotients of tan, cot, sec, csc, artanh and arcosh at a symbolic point were NaN for it. A polynomial's constant coefficient written -a^4 + a^4 made (((a + x)^2)^2 - a^4) / x answer +oo times it. CancelledDifference now also asks a constant sum, free of x and of infinities, whether Simplify reduces it to 0, keeping a condition Simplify attaches. It is applied to Sumf's descent results as Minusf's already were, and ParseAsPolynomial drops a coefficient it reduces to 0. Found by a sweep of limits at symbolic points and with symbolic parameters compared by value at five values of the parameter: on master it reports 82 rows of NaN where the values settle, on this branch 12. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2655 +/- ##
==========================================
- Coverage 86.70% 86.70% -0.01%
==========================================
Files 345 346 +1
Lines 75541 75734 +193
Branches 22075 22148 +73
==========================================
+ Hits 65501 65666 +165
- Misses 5416 5430 +14
- Partials 4624 4638 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
#2632 reads a limit that comes back as a constant minus itself as 0. A zero written any other way was still kept as a nonzero constant. A quotient over a vanishing divisor then answered
NaN, or+ootimes that constant.The fix.
CancelledDifferencenow asks one more question of a constant sum that is free ofxand of infinities: doesSimplifyreduce it to 0? Any conditionSimplifyattaches is kept. The check is applied toSumf's descent results, as it already was toMinusf's.ParseAsPolynomialdrops a coefficient that reduces to 0..Limit(x, 0)(tan(a + x) - tan(a)) / xNaN1 / cos(a) ^ 2(cosh(a x) - 1) / x^2NaNa ^ 2 * 2 / 4(cosh(a x) - 1) / x1/2 * a + -1/2 * a0(artanh(a + x) - artanh(a)) / xNaN(-1) / (a ^ 2 + -1)(((a + x)^2)^2 - a^4) / x+oo * (-a ^ 4 + a ^ 4)4 * a ^ 3The same holds for the difference quotients of cot, sec, csc and arcosh.
How it was found. A new sweep,
symlimitcheck, takes 190 limits at a symbolic point or with a symbolic parameter. It compares each answer by value at a = -5/2, -7/10, 3/5, 19/10 and 33/10 against the values approaching the point, and against the library's own limit taken with that value ofaput in first. On master it reports 82 rows ofNaNwhere the values settle; on this branch it reports 12. The rest are left as they were:absdifference quotients areNaN, by a separate mechanism (a step near the point).x^aat0+gives0with a condition that is false fora < 0.a^x / xat+ooisNaN.aon the branch cut (a = -5/2), thearcsinandarccosdifference quotients give the derivative's other sign. This is the sweep's only "another value" row, and it is the same on master and on this branch.Checks
AZeroLimitWrittenAnotherWayTesttakes each limit from both sides and from each side alone, and compares it by value at three values ofa..editorconfiggains one entry: the 2026 header template for the new test file, which IDE0073 requires.Closes #2639.
🤖 Generated with Claude Code