Repository navigation
l'Hopital's rule is not applied across the jumps of a step function - #2284
Merged
Rafael-SOWNet merged 1 commit intoOct 31, 2026
Conversation
limit(floor(x) / x, x, +oo) was 0, where it is 1, and so was limit(ln(floor(x)) / ln(x), x, +oo). l'Hopital's rule needs both parts differentiable on a punctured neighbourhood of the destination. The derivative of floor(x) is 0 provided not x in ZZ, and every neighbourhood of +oo holds integers, but the rule stripped the condition and read 0 / 1. SolveAsLogarithmDivision's own use of the rule did the same. HasAStepThatJumpsNear asks whether a floor, ceil or round has an argument that does not tend to a finite value, or a sign one that has no limit, and both uses of the rule decline there. Where the argument settles, the step is constant on either side of the destination and the rule is applied as before. LHopitalAcrossAJumpTest takes eight limits the rule answered wrongly, which must now be right or unevaluated, and five where a step settles, which are answered as before; the eight fail on master. The suite, the trio, F#, AOT and the eight harnesses pass. limit(round(x) / x, x, +oo) still throws, because round(+oo) does (#2282). Fixes #2281. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2284 +/- ##
==========================================
+ Coverage 86.70% 86.71% +0.01%
==========================================
Files 310 310
Lines 67846 67862 +16
Branches 19689 19693 +4
==========================================
+ Hits 58824 58848 +24
+ Misses 4902 4892 -10
- Partials 4120 4122 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Rafael-SOWNet
deleted the
lhopitals-rule-is-not-applied-across-the-jumps-of-a-step-function
branch
October 31, 2026 03:27
Rafael-SOWNet
added a commit
that referenced
this pull request
Oct 31, 2026
Compiled into a function returning double or float, every value computed on the way is real, so sin(arcsin(x)) at 2, which is 2, is NaN, as 1/x is at 0 where there is no value. That is the behaviour, and it is now written on every Compile overload, in the .tt templates those overloads are generated from. MathS.Settings.RefuseNonRealCompilation, off by default, refuses such an expression instead: with it on, an expression that cannot be shown real wherever it is defined throws UncompilableNodeException, so a NaN from the compiled function means only that there is no value. The showing is TreeAnalyzer.IsRealValued, with each argument written as one fresh variable, and it is conservative: sqrt(x) and ln(x) are refused too. The Complex compilers and statements are unaffected. IsRealValued now reads floor, ceil, round, min and max of real arguments as real, which the setting needs and which also answers the derivative of a modulus or a sign of one: d/dx abs(floor(x)) was left unevaluated. limit(sin(floor(x)) / x, x, +oo) is 0 again, as in 2.6.0: #2284 took away the l'Hopital route that had answered it. RefuseNonRealCompilationTest takes the default NaN, the refusals over double and float, what is real still compiled, a division by zero still NaN, and the Complex compiler and a statement unaffected. PublicApi.txt gains the setting. The suite, the trio, F#, AOT and the eight harnesses pass. Fixes #2286. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
limit(floor(x) / x, x, +oo)was0, where it is 1. l'Hopital's rule needs both parts differentiable on a punctured neighbourhood of the destination. The derivative offloor(x)is0 provided not x in ZZ, and every neighbourhood of+oocontains integers, yet the rule stripped the condition and read0 / 1.SolveAsLogarithmDivision's own use of the rule did the same.HasAStepThatJumpsNearasks whether a step function jumps arbitrarily close to the destination: afloor,ceilorroundwhose argument does not tend to a finite value, or asgnwhose argument has no limit. Both uses of the rule decline in that case. Where the argument settles, the step is constant on either side of the destination, and the rule applies as before.limit(floor(x) / x, x, +oo)0limit(floor(2x) / x, x, +oo)0limit(ln(floor(x)) / ln(x), x, +oo)0limit(ln(x) / ln(floor(x)), x, +oo)NaNlimit((x - floor(x)) / x, x, +oo)1limitright(x * floor(1/x), x, 0)0LHopitalAcrossAJumpTest: its eight cases that were answered wrongly fail on master. Five more, where the step settles, pass on both. The suite (18,278), the trio, F#, AOT and the eight harnesses pass locally.limit(round(x) / x, x, +oo)still throws, becauseround(+oo)does; that is #2282. With both, it is left unevaluated.Fixes #2281.
🤖 Generated with Claude Code