Repository navigation
Leave an exact power too large to build written, never +oo or 0 - #2437
Open
Rafael-SOWNet wants to merge 1 commit into
Open
Rafael-SOWNet wants to merge 1 commit into
Rafael-SOWNet wants to merge 1 commit into
Conversation
Past 2^24 bits an exact power was evaluated as the decimal, which is +oo past the context's range and 0 below it. A finite nonzero number became an infinity or a zero and fed exact arithmetic: 2^(10^9) - 2^(10^9) and 0 * 2^(10^9) were NaN, 2^(10^9)/2^(10^9 - 1) was NaN, 2^(10^9) > 2^(10^9 - 1) and 2^(-(10^9)) > 0 were False, and 2^(10^9) = 2^(10^9 - 1) was True. Evaluating the power node now leaves it written, for whole and rational exponents, so a Powf of an exact base never reaches the decimal. What holds it is settled by structure (a - a, 0 * a) or by exponent arithmetic (2^m / 2^n), as Simplify already does. A comparison with such a power is decided by the signs, by the exponents for one positive base, or by the logarithms of the magnitudes where they differ by more than 1e-90 of their size, computed at 120 digits. Anything else stays written: 2^(10^9) = 4^(5 * 10^8) is no longer decided. EvalNumerical refuses the power with CannotEvalException. Every row hung on 2.6.0 and none hangs here. Part of #1448. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2437 +/- ##
==========================================
- Coverage 86.87% 86.86% -0.01%
==========================================
Files 312 312
Lines 69724 69771 +47
Branches 20385 20403 +18
==========================================
+ Hits 60570 60609 +39
- Misses 4913 4918 +5
- Partials 4241 4244 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Part of #1448.
Since #2347, an exact power too large to build (past 2^24 bits) evaluated as a decimal.
2^(10^9)became+oo, and2^(-(10^9))became0. 2.6.0 hung on these. A guard keptSimplifyfrom collapsing the bare power to+oo, but differences, products and comparisons took the decimal, so they answered NaN or the wrong truth value for numbers that exist.Now:
The power stays written, in
Evaledas inSimplify, and so for rational exponents:8^(10^9/3)was+ootoo. Subtraction,0 * aand2^m / 2^nthen come out right from the existing rules.Comparisons with such a power are decided in three ways, and otherwise left undecided:
Two magnitudes that may be equal are never told apart, so
2^(10^9) = 4^(5*10^8)stays written. It wasTrueon master only because+oo = +oo.#1448's thread asked for a decimal approximation from
Evaled, and measured that today's decimals overflow to+oo. That approximation needs the v3 numerics, so #1448 stays open for it.2^(10^9)+oo2 ^ 10000000002^(-(10^9))02 ^ (-1000000000)2^(10^9) - 2^(10^9)002^(10^9)/2^(10^9 - 1)222^(10^9) * 2^(-(10^9))110 * 2^(10^9)002^(10^9) > 2^(10^9 - 1)FalseTrueTrue2^(-(10^9)) > 0FalseTrueTrue2^(10^9) = 2^(10^9 - 1)TrueFalseFalse3^(10^9) > 2^(10^9)FalseTrueTrue2^(10^9) = 4^(5*10^8)TrueTrue46655^(10^20)+ooforall n in ZZ* : 3^(n+1) divides 2^(3^n)+1All of #2347's former hang cases finish in 175–291 ms, among them
simplify (x^x - 1)^(e^(e^x)),simplify 2^(10^10)andsimplify 46655^(10^20) + 1. #2347's unshipped BREAKING-CHANGES.md entry is replaced by "An exact power too large to build is left written", measured from 2.6.0 to now.Not changed, because both come from the decimal context's exponent range, which the v3 numerics own:
2^(10^7 + 0.5), whose exponent is a decimal;(3+4i)^2000, which is+oo + +ooion master andNaNon 2.6.0.Checked on this branch:
AnExactPowerTooLargeToBuildTesthas 42 cases, 21 of which fail on master.🤖 Generated with Claude Code