Skip to content

Manual: how precision and accuracy carry through computations - #2069

Merged
rocky merged 3 commits into
masterfrom
doc-precision-accuracy
Oct 28, 2026
Merged

rocky merged 3 commits into
masterfrom
doc-precision-accuracy

Conversation

@tombouctou

Copy link
Copy Markdown
Collaborator

Following the suggestion in #2067: this collects what the precision PRs (#2050–#2067) established into the "Precision and Accuracy" section of the Manual's tutorial.

The section keeps its introduction and gets six subsections:

  • Errors in Sums and Products: absolute errors add up in a sum, relative errors in a product; exact constants add no error; cancellation, inexact zeros, and 0 times an inexact number.
  • Errors in Functions: precision from the condition number Abs[x f'[x] / f[x]]; a zero value (Log[1.`20]), an inexact zero argument, and Indeterminate where the error covers a pole.
  • Complex Numbers: the parts keep their own errors.
  • Machine Numbers: a machine number anywhere gives MachinePrecision.
  • Numerical Evaluation with N: N[expr, p] with $MaxExtraPrecision, and N[expr, {p, a}].
  • Setting the Precision: SetPrecision and SetAccuracy.

Every example is a doctest, so the text is checked along with the code. Each value was checked against WMA 15. The internals (PrecisionReal's stored precision and 64-bit value, condition_numbers, special_point_value, the second pass of N) belong in the developer's guide, which is a separate repository; that will be a separate PR.

docpipeline.py -s "Precision and Accuracy": 39 tests, all pass.

🤖 Generated with Claude Code

Collect what the precision PRs (#2050-#2067) established into the
"Precision and Accuracy" section of the tutorial: errors in sums and
products, the condition number for functions, zero values and poles,
complex numbers, machine numbers, N with $MaxExtraPrecision, and
SetPrecision/SetAccuracy. Every example is a doctest, and every value
matches WMA 15.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pytest 9.2.0 (2026-10-27) breaks pytest-benchmark 5.3.0, the latest
release: every benchmark errors with "'Function' object has no
attribute '_nodeid'" (ionelmc/pytest-benchmark#321). Since then the
benchmark job fails on every pull request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d00ed4a)
rocky pushed a commit that referenced this pull request Oct 28, 2026
Since pytest 9.2.0 came out (2026-10-27), the "Run performance
benchmarks" job fails on every pull request, including #1989, #2032,
#2069 and #2070. All 73 benchmarks error at setup:

```
AttributeError: 'Function' object has no attribute '_nodeid'. Did you mean: 'nodeid'?
```

pytest-benchmark 5.3.0, its latest release, uses a private attribute
that pytest 9.2 removed: ionelmc/pytest-benchmark#321, still open. The
last passing run (master, 2026-10-27 10:20) had pytest 9.1.1; the
failing ones have 9.2.0. pytest-benchmark is 5.3.0 in both.

This keeps pytest below 9.2 in the benchmark workflow, with a comment
pointing at the upstream issue, so the pin can go once pytest-benchmark
is fixed. `pyproject.toml` does not pin pytest, so the later `pip
install -e .[dev,full]` keeps 9.1.x.

Checked with a one-test benchmark: pytest 9.2.0 + pytest-benchmark 5.3.0
gives the same error, and pytest 9.1.1 + pytest-benchmark 5.3.0 passes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@rocky

rocky commented Oct 28, 2026

Copy link
Copy Markdown
Member

LGTM - thanks!

@rocky
rocky merged commit 5ceb5b4 into master Oct 28, 2026
15 checks passed
@rocky
rocky deleted the doc-precision-accuracy branch October 28, 2026 17:00
rocky pushed a commit to Mathics3/Mathics3-development-guide that referenced this pull request Oct 28, 2026
How the kernel tracks the error of arbitrary-precision numbers, as WMA
does: PrecisionReal's decimal precision and 64-bit value, the error
rules for sums and products, condition numbers for functions, zero
values, special points, complex parts, the second pass of N, and
SetPrecision. Ends with how to add precision to a new function.

The user-level description is in the Mathics3 Manual
(Mathics3/mathics-core#2069).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants