Skip to content

tests: pin exact golden values for deterministic math#3

Merged
NiceAndPeter merged 3 commits into
mainfrom
determinism-golden-pins
Jun 21, 2026
Merged

tests: pin exact golden values for deterministic math#3
NiceAndPeter merged 3 commits into
mainfrom
determinism-golden-pins

Conversation

@NiceAndPeter

Copy link
Copy Markdown
Owner

Per the determinism guarantee, fixed-input transcendental tests now assert the library's exact output (==) instead of accuracy-within-a-margin (fabs(lib - std) < tol). A tolerance verifies accuracy, not the bit-exact reproducibility the library advertises; exact golden pins turn these into determinism/regression locks that the multi-arch matrix (x64 + ARM64 Linux, macOS ARM, MSVC x64 + ARM) verifies.

  • test_cmath_double.cpp: sin_core, real-arithmetic compose, sqrt(9), sin/cos(47°), sin(180°) → exact.
  • test_coverage_corners.cpp: d_cbrt / d_atan2 axis cases → exact golden doubles.
  • test_storage_flags.cpp: atan/atan2 on a real grid → exact grid values (bit-identical on both the double and CORDIC engines — confirmed locally).

Kept margins only where they stay meaningful: range sweeps vs std (approximation accuracy) and the random-input fuzz harness (no fixed golden).

Local: double 352/352, CORDIC 395/395. This PR's cross-platform run is the real determinism check — if any golden pin fails on another compiler/arch, that's a genuine determinism finding to fix in the library.

🤖 Generated with Claude Code

Peter Neiss and others added 3 commits June 21, 2026 14:30
…margins)

The library advertises bit-exact determinism, but several transcendental tests
asserted only accuracy-vs-std within a tolerance (`fabs(lib - ref) < tol`), which
does not verify reproducibility. Replace the fixed-input margins with exact `==`
against the library's own output, turning them into determinism/regression locks
that the multi-arch CI matrix (x64 + ARM, GCC/Clang/MSVC/AppleClang) now verifies.

- test_cmath_double.cpp: sin_core, real-arith compose, sqrt(9), sin/cos(47°),
  sin(180°) → exact hex-float / exact constants (drop the unused std oracle + sv).
- test_coverage_corners.cpp: d_cbrt / d_atan2 axis cases → exact golden doubles.
- test_storage_flags.cpp: atan/atan2 on a real grid → exact grid values (verified
  bit-identical on BOTH the double and CORDIC engines).

Kept margins only where they remain meaningful: range sweeps vs std (accuracy of
the approximation) and the random-input fuzz harness (no fixed golden). Local:
double 352/352, CORDIC 395/395.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…grids

New tests/test_determinism.cpp pins the exact (==) output of asin, acos, sinh,
cosh, tanh, log10, hypot, pow — plus added corner cases for sqrt, cbrt, atan,
atan2, sin, cos, tan — across a VARIETY of grids (notch 1/256…1/65536, different
intervals, real storage) and domain corners (0, ±1, edges, axes, quadrants), and
the sqrt error path. ~110 exact assertions; values captured from the library and
verified bit-identical on BOTH engines except one coarse-grid sinh (per-engine
#ifdef). Locks bit-exact determinism, now checked across the x64+ARM × GCC/Clang/
MSVC/AppleClang matrix.

Local: double 361/361, CORDIC 404/404.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ue-identical

State explicitly that the double and integer/CORDIC engines, while each
bit-reproducible per engine, can differ by up to one output notch on some
transcendental inputs (table-maker's dilemma — worked sinh(4) example), so
switching engines is NOT value-preserving: golden/record-replay data is valid
within one engine only. Corrects math.md's "interchangeable" / "value does not
depend on the engine" claims; adds a per-engine caveat to determinism.md's TL;DR
and a new subsection.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@NiceAndPeter NiceAndPeter merged commit 61295db into main Jun 21, 2026
16 checks passed
@NiceAndPeter NiceAndPeter deleted the determinism-golden-pins branch June 21, 2026 17:12
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.

1 participant