Repository navigation
Read a power's domain condition over the reals and off the real line - #2747
Merged
Merged
Conversation
Over the reals a negative base has a real power only where the exponent is a whole number or a fraction of odd denominator below 10, whose real root the library takes. Powf.IntrinsicCondition restricted the base only for a literal even root, so x^pi, x^x and (-1)^x were taken as defined where their real reading is NaN, and x^(1/11) too, whose principal root is not real. The condition is now x >= 0 for any other number, and for a symbolic exponent e it names the fractions the real root is taken for: x >= 0 or 5e in ZZ or 7e in ZZ or 9e in ZZ, the numbers whose denominator divides 5, 7 or 9. That is exactly the library's set, so the condition is not stricter than the values. Off the real line the zero-base part said w > 0 for an exponent that is not a number, which has no value at a non-real w: domain(0^x) was NaN at 1 + i, where 0^(1 + i) is 0. It reads Re(w) > 0 now, as #1865 did for a constant exponent, and so does the incomplete gamma function's condition at a lower limit of 0. Simplify(0^x) wrote its condition as x (1 + 1/sgn(x)^2) > 0, which had no value at 0; it writes Re(x) > 0. PredicateEntailment reads through Re so x^x provided not x = 0 still drops its redundant condition. Measured on 9b75a26 and this branch: domaincheck's real "holds where the real reading has no value" goes from 98 to 9 in random compositions (the 9 left are lambertw at -1/e and a polygamma row) and from 4 to 2 in the listed nodes, with "fails where it has a value" unchanged (105, 6). The sweep's 18383 real-reading rows: 263 too loose and 63 undecided become right, none newly wrong; its 76513 complex rows: 106 undecided become right, none newly wrong. CasBench, RootCheck, SimpSweep, PropCheck and BoundCheck agree on both. Unit suite 22399 passed, 0 failed; the new tests fail on master in 17 rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2747 +/- ##
=======================================
Coverage 86.70% 86.71%
=======================================
Files 347 347
Lines 77376 77387 +11
Branches 22783 22786 +3
=======================================
+ Hits 67089 67103 +14
+ Misses 5546 5543 -3
Partials 4741 4741
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…onent unwrapped The condition 0^w needs, Re(w) > 0, was built afresh for every power node and simplified from the start: carried through a sum, each part asked whether it is real. A simplification builds many powers over one exponent, so the kernel benchmark's SimplifyHard allocated 8.9% more, and Derivate 4.2% more from Re(-1/2) around an exponent that is already a real number. A real number is now its own real part, unwrapped, and the simplified Re(w) > 0 is kept per exponent instance in a ConditionalWeakTable, under the settings it was simplified in, as a node's own simplification is. Allocated bytes per operation, base 9b75a26 against this branch, two interleaved runs each, identical in both runs: Derivate 24,624 -> 24,624 B (PR head before this: 25,656) SimplifyHard 134,975,155 -> 133,718,291 B, -0.9% (PR head: 147,012,144) No answer changes: 560 domain, simplify and derivative inputs over powers with symbolic, complex and real exponents print the same on the PR head and on this commit, under the complex and the real codomain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each was 0^y under a function, whose normalisation was 0 provided y / 2 * (1 + 1 / sgn(y) ^ 2) > 0; the canonical order rearranged that product again when applied a second time. It is now 0 provided Re(y) > 0, which a second sort leaves as it is. 0 appeared. 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.
What was wrong
domain(x^pi, RR),domain((-1)^x, RR)anddomain(x^(1/11), RR)wereTrue, andx^xwas accepted at -1/2, at points where the real reading isNaN.w > 0for an exponent that is not a number.w > 0has no value at a non-realw, sodomain(0^x)wasNaNat1 + i, where0^(1 + i)is 0.The fix
x >= 0;egetsx >= 0 or 5e in ZZ or 7e in ZZ or 9e in ZZ. Those are exactly the fractions whose denominator divides 5, 7 or 9, so the condition matches the values and is no stricter than them.Re(w) > 0, as Zero times a power with a non-real exponent is NaN #1865 already did for a constant exponent. The incomplete gamma function's condition at a lower limit of 0 gets the same change.Simplify(0^x)wrote its condition asx (1 + 1/sgn(x)^2) > 0, which has no value at 0. It is nowRe(x) > 0.PredicateEntailmentnow reads throughRe, sox^x provided not x = 0still simplifies tox ^ x.What I measured (master 9b75a26 against this branch)
domaincheck, rows where the real condition holds but the real reading has no value:lambertwat -1/e and onepolygammarow, neither a power.Re.Allocation (kernel benchmark cases, bytes per operation, two interleaved runs each, the same in both)
The first head allocated more for every power over a symbolic or rational exponent. Each power node built a fresh
Re(w) > 0and simplified it from the start, andRe(-1/2)was wrapped around an exponent that is already real. Now a real number is its own real part and stays unwrapped, and the simplifiedRe(w) > 0is kept per exponent instance under the settings it was simplified in.No answer changed from the first head. 560 domain, simplify and derivative inputs over powers with symbolic, complex and real exponents print the same on both builds, under the complex and the real codomain.
CanonCheck: 0 findings appeared and 12 went away, and they are recorded in
canoncheck-baseline.tsv. All 12 areCanonicalOrderExactidempotence findings on0 ^ yand its relatives:0 ^ y,0 ^ x,0 ^ a,-0 ^ y,(0 ^ y) ^ 2,abs(0 ^ y),cos(0 ^ y),sin(0 ^ y),sgn(0 ^ y),sqrt(0 ^ y),ln(0 ^ y),e ^ 0 ^ y. Each used to normalise to0 provided y / 2 * (1 + 1 / sgn(y) ^ 2) > 0, and a second sort rearranged that product again. Each now normalises to0 provided Re(y) > 0, which a second sort leaves alone.After merging master 8b4f507: UnitTests 22574 passed, 0 failed. SimpSweep 10463/10463 agree. BoundCheck 0 disagreements. PropCheck passes. CanonCheck matches the updated baseline (2028 findings).
Fixes #2739
Fixes #2740
🤖 Generated with Claude Code