Repository navigation
Do not read a power that is not real on the side approached as a real one - #2696
Merged
Merged
Conversation
… one x^(x - 1) and (e^x - 1)^(x - 1) at 0 from the left were +oo, where the principal value tends to -oo + i pi (-1.0E+20 + 3.1415927i at x = -1e-20, by mpmath). Traced at the dispatcher: the one-sided descent stops at 0^(-1), and the substitution to +oo hands (-1/x)^(-1/x - 1) to Gruntz's algorithm, whose leading term is e^(-(i pi - x) - x) / w. Sign read every exponential as positive; e^(-i pi) is -1. An exponential is now positive to it only where its exponent is real, and the limit is left unevaluated, as sin(x)^(x - 1) there already was. Introduced in #1627 (371b38e), which made the algorithm answer at all here; its parent left these unevaluated. Two-sided, the comparison of the sides took a side that came back NaN to agree with the other, since ExpressionNumerical.AreEqual passes over a point where either value is NaN: (x^2 - x)^(x - 1) at 0, +oo from the left and not real from the right, was +oo. A side that is NaN no longer agrees, and it is NaN, as (-x)^x at 0 is. A sweep of f^g, f^g x and f^g / x at 0 from each side and two-sided, f in {x, sin x, e^x - 1, tan x, x^2 - x, x/(1 - x)} and g in eight exponents, 432 rows against mpmath at 1e-20, 1e-40 and 1e-80: 31 wrong on master, 0 here. Fixes #2693 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2696 +/- ##
==========================================
- Coverage 86.62% 86.61% -0.01%
==========================================
Files 346 346
Lines 76734 76754 +20
Branches 22546 22554 +8
==========================================
+ Hits 66470 66482 +12
- Misses 5537 5546 +9
+ Partials 4727 4726 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Member
Author
Rafael-SOWNet
added a commit
that referenced
this pull request
Dec 4, 2026
…tion settles in (#2702) 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 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>
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 #2693
Cause
x^(x - 1)at 0 from the left: the one-sided descent stops at0^(-1), and the fallback that moves the point out to+oohands(-1/x)^(-1/x - 1)to Gruntz's algorithm (traced at the dispatcher). The algorithm's leading term ise^(-(i pi - x) - x) / w, andGruntz.Signread every exponential as positive, so it answered+oo. Bute^(-i pi)is-1, and the principal value tends to-oo + i pi(-1.0E+20 + 3.1415927iatx = -1e-20, mpmath). An exponential is now positive to the algorithm only where its exponent is real. Otherwise the sign is undecided, and the limit is left unevaluated, assin(x)^(x - 1)there already was (AnExponentThatOnlyTendsToAWholeNumberIsLeftAloneUnderANegativeBase).Introduced in #1627 (371b38e), which first let the algorithm answer here. Its parent leaves these limits unevaluated. NuGet 2.5.0 has them unevaluated and 2.6.0 has
+oo.A second fault was found by the sweep. In a two-sided limit,
ExpressionNumerical.AreEqualskips any point where either value is NaN, so a side that came back NaN "agreed" with the other side.(x^2 - x)^(x - 1)at 0 is+oofrom the left and not real from the right, and it was+oo. A NaN side no longer agrees, so the limit isNaN, as(-x)^xat 0 already is (AComplexSideIsNotRead).Measured
The sweep covers 432 limits at 0:
f^g,f^g * xandf^g / x, each from the left, from the right and two-sided, forfin {x, sin x, e^x - 1, tan x, x^2 - x, x/(1 - x)} andgin {x, x - 1, x - 2, x + 1, 2x - 1, x^2 - 1, 1/2 + x, -x}. Each answer is checked against mpmath's principal value at ∓1e-20, ∓1e-40 and ∓1e-80.NaN.x^(x - 2)family (12 rows) is now unevaluated. On master it was+ooor-ooin the right direction, but the imaginary part also grows without bound.sin(x)^(x - 2)at 0 from the left is already pinned as unevaluated.tan(x)^(±x) * xtwo-sided went from0toNaN, the pinned answer for a two-sided limit with a non-real side.NaNto unevaluated.x^x,sin(x)^xandx^(x - 1) * xat 0 from the left are still1.Suites and harnesses:
New test file:
ANonRealSideIsNotReadAsRealTest. BREAKING-CHANGES entry: A power that is not real on the side approached is not read as a real one.🤖 Generated with Claude Code