Repository navigation
Form a complex product past the exponent range before rounding it - #2348
Merged
Merged
Conversation
A complex number's parts are decimals in the precision context, whose exponents end at 1e1000. A product or a whole power of finite numbers, a part of which passed that end on the way, had oo - oo in it and was NaN: (3+4i)^2000, (1+i)^(10^6) and (1e600+1e600i)^2, and Simplify returned the NaN as well. 2.6.0 does the same. A complex product whose parts leave the range is formed with unbounded exponents and each part rounded into the context, and a complex power that does is raised the same way. Each part past the range is the infinity of its sign, as a real past it is +oo; within the range nothing changes, since the bounded result is used whenever it is finite. (1+i)^(10^6) is +oo and (1e600+1e600i)^2 is +oo i. The guard against an infinity only rounding made now covers any sum, product or power of exact finite operands (a power's base not zero), which is exact and finite, so an exact simplification leaves (3+4i)^2000 as written. An operand that is already a decimal is not covered: the integrator reads a decimal sample past the range as +oo, and taking that away made one Rubi antiderivative 23,030 characters long. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2348 +/- ##
==========================================
- Coverage 86.77% 86.76% -0.01%
==========================================
Files 312 312
Lines 68645 68664 +19
Branches 19980 19987 +7
==========================================
+ Hits 59567 59577 +10
- Misses 4910 4918 +8
- Partials 4168 4169 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
IsFinite is a cache made on an entity's first read of it, and each number an evaluation or a power produces is a new entity. Asked of every exact value in the exact-evaluation shortcut (the guard #2347 added) and of every power built (the check this branch added), it cost about 250 KB and 237 KB on each solve of the kernel benchmark's SolveHard, +5.1% against the gate's baseline. The parts answer the same question without the cache, a rational part being finite as it is. The size bound #2347 added is computed in longs as well; it measured free as EIntegers, but it is asked of every exact power. SolveHard allocates 9,549,209 B, against 9,546,434 B before #2347 and 10,027,870 B before this commit. 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.
A complex number's parts are decimals in the precision context, whose exponents end at 1e1000. A product or a whole power of finite numbers that had a part pass that end had
oo - ooin it and came outNaN, which says the value does not exist.Simplifyreturned the sameNaN. 2.6.0 does the same. A compilesweep follow-up found it; no issue was filed."(3+4i)^2000".EvalNumerical()NaN+oo + +ooi(each part the sign of the exact part)"(1+i)^(10^6)".EvalNumerical()NaN+oo"(1e600+1e600i)*(1e600+1e600i)".EvalNumerical()NaN+ooi"(3+4i)^2000".Simplify()NaN(3 + 4i) ^ 2000(3+4i)^1400,(3+4i)^(-2000)0(1e600+1e600i)/(1e-600+1e-600i)is stillNaN, because1e-600is below the context's exponent floor and the divisor evaluates to 0. That is a separate, known limit.+oo, and the first version of this guard took that away: one Rubi antiderivative came back 23,030 characters long.Allocation. The kernel gate failed SolveHard at +5.1% on the first commit. #2347 had already moved it +2.6%, inside the 3% limit. Both halves came from reading
IsFinite, a cache built on each entity's first read: #2347's guard read it on every exact value, and this branch's power check on every power built. The second commit reads finiteness from the parts instead, and computes #2347's size bound inlongs. SolveHard allocates 9,549,209 B, against 9,546,434 B before #2347.Tests:
AComplexOverflowIsNotNaNTest, 12 cases. For each Gaussian power, the test checks the sign of every part against the exact Gaussian integer. 10 fail on master; the 2 controls pass on both. The full suite, AOT and the nine harnesses pass. There is a BREAKING-CHANGES entry, measured on 2.6.0.🤖 Generated with Claude Code