Repository navigation
Answer a limit on a side that is not real with the infinity its direction settles in - #2702
Merged
Rafael-SOWNet merged 2 commits intoDec 4, 2026
Merged
Conversation
…tion settles in x^(x - 1) at 0 from the left, left unevaluated by #2696, is -1.0E+20 + 3.1i at x = -1e-20 (mpmath): its modulus grows and its argument settles at pi, so it is -oo, as ln(x) there already is. Gruntz's algorithm now reads the direction of a leading coefficient that has no real sign, where it settles on an axis: +oo, -oo, +ooi or -ooi. Off the axes (x^(x - 1/3), at -pi/3) it declines. A term is read as growing only when w is real: x^(1/x) at 0 from the left, whose phase pi/x keeps turning, was +oo and now declines, as do six more wrong +oo rows. A root of an argument tending to -oo off the real line takes its direction from the side of the cut, and is declined in the algorithm and in the descent: sqrt((-x)^(x - 1)) at 0 from the right tends to -ooi. The logarithm of an infinity in any direction is +oo, where ln(sqrt(x) / x) at 0 from the left was ln(-ooi). Two sides agreeing on an infinity, where one is not real through a power to a moving exponent, stay NaN, as (-x)^x at 0 is. AnExponentThatOnlyTendsToAWholeNumberIsLeftAloneUnderANegativeBase pinned sin(x)^(x - 2) and sin(x)^(x - 1) at 0 from the left as unevaluated; they are +oo and -oo. FromTheLeftNothingChanges pinned (sqrt(x) - erf(x)) / x there as unevaluated; it is -ooi, as sqrt(x) / x is. #2693's left-side rows now expect their directions. A sweep of 1024 rows (the #2693 432, exponents tending to non-integers or not settling, products with ln, sqrt and constant powers, and rows at +-oo) against mpmath at 1e-10, 1e-20 and 1e-40: 7 wrong on master (and two more at the infinities), 0 here. Fixes #2697 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tive keeps a direction The rule is a theorem about real functions; its proof is Cauchy's mean value theorem, which fails for a complex-valued denominator: x / (x + x^2 e^(i/x^2)) at 0 from the right tends to 1 (1.0 - 7.8E-9i at x = 1e-8, by mpmath), while the quotient of the derivatives tends to 0. It holds where the denominator's derivative is c h' with h' real, the quotient then being the real rule's over h, part by part; ln(x) at 0 from the left, ln(abs(x)) + i pi, qualifies. A derivative seen to turn beside the destination declines the rule, after the quotient is tried upside down: x^pi / log(x, 2) at 0 keeps its 0 that way. A power of a negative base to a moving exponent declines it too, for its cost: directed sub-limits let the rule differentiate such powers chain after chain, and x^(x - 1) * x at 0 from the left took 5 s to reach 1, (-x)^(x - 1) sqrt(x) at 0 from the right 8 s. Both are under 0.3 s now, and the 1038-row sweep runs in 32 s against master's 50 s with the same answers as before this commit; the complex-denominator rows are declined, as on master. Part of #2697 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2702 +/- ##
========================================
Coverage 86.61% 86.62%
========================================
Files 346 346
Lines 76754 76864 +110
Branches 22554 22604 +50
========================================
+ Hits 66483 66582 +99
- Misses 5546 5547 +1
- Partials 4725 4735 +10
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
fix-2697-directed-infinity-on-a-non-real-side
branch
December 4, 2026 07:17
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.
Fixes #2697
#2696 left
x^(x - 1)at 0 from the left unevaluated, where Gruntz's algorithm had reade^(-i pi)as positive and answered+oo. The principal value there is-1.0E+20 + 3.1iatx = -1e-20(mpmath): the modulus grows and the argument settles atpi. That is the directed infinity-oo, the same kind of answerln(x)at 0 from the left already gets.What changed
Gruntz.cs). At the top-level limit, a termc * w^pwithp < 0whose coefficient has no real sign is now read for its direction. Wherectends to a non-zero number, or to an infinity with a direction, on one of the axes, the answer is+oo,-oo,+ooior-ooi. A direction off the axes declines:x^(x - 1/3)settles at-pi/3, and the library has no node for that direction. A conclusion that a term grows without bound now needswto be real. Wherewis written through an exponent that is not real, its argument can keep turning.x^(1/x)at 0 from the left (phasepi/x) was+ooon master and now declines, and so do six other rows in the sweep below. Two more guards:sin(x)^(x - 2)at 0 from the left be read.-oooff the real line now declines, because which side of the cut the argument comes from decides the answer.Limit.Classes.cs,Transformations.cs). The same cut check is applied to a power's base tending to-oo.sqrt((-x)^(x - 1))at 0 from the right comes to the cut from below and tends to-ooi, and would otherwise have been+ooi. The logarithm of an infinity in any direction is+oo:ln(sqrt(x) / x)at 0 from the left wasln(-ooi)on master.Transformations.cs). The rule is a theorem about real functions. Its proof rests on Cauchy's mean value theorem, which fails for a complex-valued denominator:x / (x + x^2 e^(i/x^2))at 0 from the right tends to 1 (mpmath gives1.0 - 7.8E-9iatx = 1e-8), while the quotient of the derivatives tends to 0 (3.9E-9 - 3.1E-9i). The rule now applies only where the denominator's derivative keeps one direction beside the destination:g' = c h'withh'real. That condition is sufficient. The denominator is theng = c h + d, the quotient is the real rule's overh, applied to the numerator's real and imaginary parts separately, anddeither vanishes against a growinghor is real wherehvanishes.ln(x)at 0 from the left isln(abs(x)) + i pi, and its derivative1/xis real, so the rule still applies to it.1/gover1/f.x^pi / log(x, 2)at 0 keeps its 0 that way.x^(x - 1) * xat 0 from the left took 5 s to arrive at its 1, and now takes 0.2 s.Solvers.Definition.cs). Where both sides agree on an infinity, one side is witnessed not real, and the expression holds a power to a moving exponent that is not real on both sides, the limit staysNaN. This is the convention(-x)^xat 0 already follows.x^(x - 1) / xat 0 is+oofrom each side and staysNaN.ln(x)at 0 stays-oo.Measured on master
82eb869e1and on this branch.f^gwith exponents tending to non-integers or not settling, and products withln,sqrt,x^(±1/2),x^(±1/3),x^(-3/2)and(-x)^a, all at 0 from each side and two-sided. It also has 72 rows at±oo, and 14 quotients over a complex denominator where l'Hôpital's rule fails:x / (x + x^2 e^(i/x^2)),sin(x)over the same,(1/x) / (1/x + x e^(i/x^2)),x / (x + x^2 e^(i/x)), and two at+oo. Every row is checked against mpmath principal values at∓1e-10,∓1e-20and∓1e-40, once at those points and once at 1.2345678 times them. The second set is needed becausepi/xis a multiple of2 piat1e-10itself. Each answer is classified by modulus and byarg.NaNwith a non-real side, 231 declined, 7 wrong. Two more wrong answers at the infinities were classified "right" because of where the sample points fell:(-x)^xat+ooandx^(-x)at-oo, both+oo, where the phasepi xturns.NaNwith a non-real side, 55 declined, 0 wrong. The complex-denominator rows are declined on both.1, andNaNtwo-sided where the sides differ).NaNwith a non-real side.+ooanswers became declined.NaNs that became declined:x^(1/x)and similar at 0, where the left side no longer answers. The l'Hôpital guard costs no row of the sweep.AGrownQuotientIsReadWithoutAnotherStepTest.FromTheLeftNothingChangespinned(sqrt(x) - erf(x)) / xat 0 from the left as unevaluated. Its value is-1.1 - 1.0E+10iatx = -1e-20, so it now expects-ooi, which is whatsqrt(x) / xthere already is.AnExponentThatOnlyTendsToAWholeNumberIsLeftAloneUnderANegativeBasenow expectssin(x)^(x - 2)to be+ooandsin(x)^(x - 1)to be-oo. The limits of x^(x - 1) and (e^x - 1)^(x - 1) at 0- are +oo; the principal value tends to -oo + pi i #2693'sIsLeftUnevaluatedFromTheLeftrows now expect their directions. New tests are inADirectedInfinityOnANonRealSideTest, including two complex-denominator quotients that must not be answered 0.NaNwhere settled are on master too)Cost. The sweep took 32 s on the branch against 50 s on master, run back to back. No row is slower than master by more than 1.5x or 1 s, whichever is larger. Only four rows take over 1 s on either side, and all four are complex-denominator rows, declined on both:
(1/x) / (1/x + x e^(i/x^2))at 0x / (x + x^2 e^(i/x^2))at 0sin(x) / (x + x^2 e^(i/x^2))at 0(1/x) / (1/x + x e^(i/x^2))at 0 from the leftThe first version of this branch did not have the l'Hôpital guard, and its sweep took 159 s. With directed sub-limits available, nested l'Hôpital steps ran over complex numerators, for example
(-x)^(x - 1) * sqrt(x)at 0 from the right went from 0.1 s to 8 s. The guard removes all of that. limitcheck took 28 and 28 s on master against 29 and 28 s on the branch, and symlimitcheck 25 and 25 s on each, run alternately.BREAKING-CHANGES.mdhas an entry. A-ooon a side that is not real is a direction, not the real negative infinity, asln(x)at 0 from the left already is.🤖 Generated with Claude Code