Repository navigation
Read a limit's value at a continuous point before simplifying - #2365
Merged
Merged
Conversation
A limit at a finite point moves the variable out to infinity, x = a +- 1/x, and simplified that whole expression before reading its value there -- which is what the substitution answers a continuous point with in any case, under the same guards for a jump, a cut and an indeterminate power. Simplifying was the expensive half: x / (tanh(1/2) - tan(x)) at 1 took 10 s and tanh(x) / (tanh(1/2) - tan(x)) 18 s, for values read in milliseconds. The substitution is now asked first as well, and answers where its value is a finite real; a complex one can be the value on a cut, whose guards were written against the simplified form. A tangent can come back as the quotient of its sine and cosine. Reading first hands the descent an argument's limit folded -- -1 rather than -1 - 1/+oo -- and the factorial's descent put it straight into x!, writing down the pole: x! at -1 was (-1)!. The factorial declines at a negative integer now. limitcheck, DEPTH=3, seeds 14, 16, 19, 23, 26, 28, 29 against master f3e514a: 667 s -> 437 s, "did not finish in 5 s" 13 -> 1, compared 36275 -> 36294, the wrong values unchanged. "NaN where the values settle" 84 -> 85: two wrong NaNs gone (abs(x + 1 - x^x) at 0 from each side, now unevaluated), three limits NaN that were unevaluated, each an expression with no real values on a side, which is the convention x^x at 0 is pinned to. Found at SEED=28; no issue was filed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2365 +/- ##
==========================================
+ Coverage 86.77% 86.78% +0.01%
==========================================
Files 312 312
Lines 68855 68861 +6
Branches 20063 20066 +3
==========================================
+ Hits 59746 59762 +16
+ Misses 4923 4909 -14
- Partials 4186 4190 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This was referenced Nov 4, 2026
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.
x / (tanh(1/2) - tan(x))at 1 took 10 s, andtanh(x) / (tanh(1/2) - tan(x))at 1 took 18 s, at points where both are continuous. limitcheck atSEED=28had thirteen limits that did not finish in 5 s, and twelve of them were these.A limit at a finite point moves the variable out to infinity,
x = a ± 1/x. It then simplified the whole expression before reading its value there. That value is what the substitution answers a continuous point with in any case, under the same guards for a jump, a cut and an indeterminate power, and simplifying was the expensive half.The substitution is now also asked first, and it answers where its value is a finite real. It stays out of complex values, since a complex value can be the value on a cut, and the cut guards were written against the simplified form. One difference of form: a tangent can come back as the quotient of its sine and cosine.
One guard was owed. Reading the value first hands the descent an argument's limit already folded,
-1rather than-1 - 1/+oo. The factorial's descent put that straight intox!and wrote down the pole, sox!at -1 came back(-1)!. The factorial now declines at a negative integer.limitcheck, DEPTH=3, seeds 14, 16, 19, 23, 26, 28 and 29, against master f3e514a:
Read the last row.
NaNs are gone.abs(x + 1 - x^x)at 0 from each side is now unevaluated.NaN:sin(x)^(log(x, pi)^arcsin(x))at 1,(2(x - pi))^ln(-x)at 0, andarctan((-1)^x)^(pi/x/cos(2))at 1/2. Each has no real values on a side:(-oo)^(pi/2)from the left,ln(-x)forx > 0, and(-1)^xthroughout. A side with no real values making no two-sided limit is the conventionx^xat 0 is pinned to, byLimitTest.TestNoLimit, and limitcheck flagsx^xthe same way in every run.I tried making the two-sided path claim
NaNonly where both sides are decided in full. That took these three back to unevaluated, but it also unpinnedx^x,x ln xandsin(x) ln x. That is a decision about the convention and not a side effect to slip into a speed fix, so it is not here.Every changed answer is recorded in BREAKING-CHANGES.md. Suite, AOT and the harnesses are green locally.
Found by limitcheck at
SEED=28; no issue was filed.🤖 Generated with Claude Code