Repository navigation
Precision: a machine number anywhere gives MachinePrecision, as in WMA - #2059
Merged
Merged
Conversation
Part of MATH-227 (an older difference noted in #2050). Precision[{{a, 2, 3.2`}, {2.1``3, 3.2``5, "a"}}] was 3.32222, the lowest precision of the numbers; WMA gives MachinePrecision, as it does whenever the expression holds a machine number. A flat list only got that right because the lowest value happened to be the machine precision. The check is now on the numbers themselves, so an arbitrary-precision number with 15.9546 digits keeps its value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… as in WMA Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
LGTM. Feel free to merge when CI finishes. |
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 #2047: the older difference noted in #2050. Independent of the other open PRs: this one is against master.
In WMA,
Precisionof an expression that holds a machine number isMachinePrecision, whatever the other numbers are:Precision[{{a, 2, 3.2`}, {2.13, 3.25, "a"}}]3.32222MachinePrecisionMachinePrecisionPrecision[{1.5`10, 1.5}]10.MachinePrecisionMachinePrecisionPrecision[f[1.5`3, x, 2.]]3.MachinePrecisionMachinePrecisionPrecision[{1.5`20, 1.5}]MachinePrecisionMachinePrecisionMachinePrecisionA flat list such as
{1.520, 1.5}was right only because its lowest precision happened to equal the machine precision. The check now looks for a machine number in the expression (has_machine_number), not at the value. So an arbitrary-precision number with 15.9546 digits, such asN[Pi, $MachinePrecision]`, keeps its value, as in WMA.Tests
In
test_precision, the two lists from the table expected3.andPrecision[2.13]. They now expect `MachinePrecision`. Three new cases. The `Precision` doctest `Precision[{{1, 1.`},{1.`5, 1.`10}}]` expected `5.`; WMA gives `MachinePrecision`. It now shows both: with1.20`` in place of ``1.``` it gives5.`. Full run on kimmy: doctests all pass (4605). The pytest failures are the ones that depend on the order the tests run in; the failing files that touch numbers pass on their own.🤖 Generated with Claude Code