Repository navigation
Keep an exact number past the working digits exact (#2615) - #2620
Conversation
At a hundred digits, a product past about 10^50 evaluated to a decimal whose last digits were rounded to 0. Real.Create read that decimal as an integer, and since an Integer is exact, InnerSimplified and Simplify put it in place of the exact expression: 2^340 sqrt(2) became a 103-digit integer, and sqrt(2)^800 / 2^400 a fraction that is not 1. A value is now downcast only where the working digits reach the downcasting tolerance below its point, that is, below the tolerance times ten to the precision. A machine number is exempt: all of its digits are exact. Past the decimals' exponent range, a rational reads as not finite through IsFinite. The guards that keep an infinity or a zero made only by rounding from being taken as an exact value asked IsFinite of their operands, so 2^4000 sqrt(2) simplified to +oo and 2^(-20000) sqrt(2) to 0. They now count a rational as finite however large, and an operand written exactly whose value is a decimal, such as sqrt(2), as finite too. An exact base to a decimal exponent past the size a power is built to is left written, as it is for a whole exponent that large. 46655^(e^(e^6)) had reached that arm only because e^403 was taken for an integer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2620 +/- ##
==========================================
+ Coverage 86.70% 86.72% +0.02%
==========================================
Files 345 345
Lines 75428 75559 +131
Branches 22034 22083 +49
==========================================
+ Hits 65397 65530 +133
+ Misses 5418 5410 -8
- Partials 4613 4619 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Every number the parser reads is downcast, and the check built ten to the precision and a product for each: CI's allocation gate measured ParseEasy 7.1% and ParseHard 3.6% above the baseline. A magnitude a digit or more either side of the bound is now decided in doubles, which allocate nothing; only one near it is compared exactly. Measured over 2000 parses: 19656 -> 18456 B/op and 61608 -> 60100 B/op, against 18360 and 59478 on master 00813f6. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing-change entries Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Blocked before merge. Merged with master, this branch fails Also fixed on the branch: CI's allocation gate failed on |
y^2 - 2 = 0, x^2 + (P - Q y) x - c = 0, with (1 + sqrt(2))^n = P + Q sqrt(2), has four solutions. Since #2612 the eliminator also solves for y from the second equation, through ((x^2 + P x - c)/(Q x))^2 = 2, a quartic in x with coefficients near Q^2. At n = 90 the small root of that quartic, exact, evaluated to a residual of -0.042 against terms of 3 at a hundred digits, and no interval enclosure of it could be worked out. It was dropped as spurious, and the system was answered with three rows. Master answers three rows of four at n = 80, 90, 100 and 120 for several c. 2.10.0 declined all of them. Merged with #2620, which keeps P + Q sqrt(2) exact, the same happens at n = 70 in the system's own row check: the row's residual evaluates to -7.2e-21, while its enclosure leaves zero out by only about 6e-53. StatementSolver.Weigh now reads such a residual as rounding having reached the root, and whether it is one cannot be told. That is so where an enclosure leaves zero out but is within what IsEvidenceAgainst lets rounding leave, and where no enclosure can be worked out and twice the digits evaluate the residual to something else. A one-variable solve then declines the equation, as ShownNotARoot already did, and a system declines in RowsThatHold. A residual that more digits leave where it was is still evidence, so an extraneous root is still dropped. Every case measured is now four rows or a decline, on master and on master merged with #2620. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A number that evaluation had rounded was taken as an exact value in three places. This PR fixes all three, plus one test that had depended on the first.
Real.Createread a rounded decimal as an integer. At 100 digits, a product past about10^50comes out with its last digits rounded to 0. Simplify then used that integer in place of the exact expression.CannotBeZero,IsFiniteRoundedOntoAnInfinity) askedIsFinite. That reads a rational through the decimals, so2^4000and2^3400counted as not finite. As a result,2^4000 * sqrt(2)simplified to+ooandsqrt(2) / 2^3400to0.sqrt(2), also counts as finite.46655^(e^(e^6))had reached that arm only becausee^403was taken for an integer, andAnExactPowerTooLargeToBuildTestpins it.2^340 * sqrt(2)3167477390…78327512170002239744742…607115776 * sqrt(2)sqrt(2)^800 / 2^4001231312693…/1231312693…, not 1110^200 * pi / 10^1997853981633…/2500000000…10 * pie^7001014232054…followed by about 200 zerose ^ 7002^4000 * sqrt(2)+oo1318204093… * sqrt(2)2^(-20000) * sqrt(2)0sqrt(2) / 3980276840…integral(exp(x), x, 0, 300)1942426395…41999…9e ^ 300 - 1integral(exp(-x^2) * 10^100, x, -oo, +oo)1772453850…10^100 * sqrt(pi)Blast radius. I diffed 79 answers with large constants (
eval,simplify,solve, integrals, limits, sums, comparisons) against master.evalnow printing aRealdecimal (for example9.99…E+149) where it used to print a rounded integer.sqrt(2)^400 = 2^200,2^4000 * 3 - 2^4000 * 2 = 2^4000.Tests
AMachineNumberIsMadeAsBeforeTest(4 failures, fixed by the machine-number exemption) andAnExactPowerTooLargeToBuildTest(fixed by item 3).DocCommentPlacementTest. That came from a summary I had inserted inside another member's doc comment. I moved it and reran that test and the power test (43 passed). I did not rerun the full suite after that comment-only fix.The
BREAKING-CHANGES.mdentry is included.Closes #2615.
🤖 Generated with Claude Code