Part of #903. Extends the math constants from the 4-component (~ 212-bit) ceiling to arbitrary precision on demand.
Scope
Phase E.1 (#887, PR #893) shipped `elreal_pi`, `elreal_e`, `elreal_ln2`, `elreal_ln10`, `elreal_sqrt2`, `elreal_sqrt3`, `elreal_phi`, plus pi multiples / fractions. All are built from the precomputed 4-component expansions in `qd_constants.hpp`, capping the constants at ~ 212 bits. This phase replaces the 4-component fallback with on-demand-deeper computation.
Deliverables
O.1 BBP-style pi extraction
The Bailey-Borwein-Plouffe formula computes the n-th hexadecimal digit of pi directly, without computing the preceding digits. The lazy generator at depth k pulls 4*k more hex digits (a constant amount of work per depth step). Wire this into `elreal_pi` so the existing 4-component leading expansion remains the depth-0 path and the BBP generator kicks in for k >= 4.
O.2 Taylor truncation for e
The exp(1) series converges fast. Each additional term doubles the precision. Wire as a generator on `elreal_e`.
O.3 Taylor truncation for ln2 / ln10
`ln(1 + x)` Taylor on a small-residual argument. The same approach extends to `ln10 = ln2 + ln(5)`. Wire as generators.
O.4 Newton iteration for sqrt2 / sqrt3
Reuse the Phase L Newton-sqrt generator (so this Phase is gated on Phase L).
Acceptance
- `elreal_pi.refine_to(1024)` returns ~ 1024 bits of pi (verified against MPFR or an external high-precision pi source -- consult, do not vendor, the value)
- Same for `elreal_e`, `elreal_ln2`, `elreal_ln10`
- `elreal_sqrt2`, `elreal_sqrt3` refine to arbitrary depth once Phase L lands
- The picker decision tree note about "constants are dd/qd-deep only" goes away
- Builds clean under gcc and clang
Dependencies
- Phase L (Newton refinement) is required for `elreal_sqrt2` / `elreal_sqrt3` past 4 components
- Phase N (Payne-Hanek) becomes more useful once `elreal_pi` is deeper; argument range for trig grows linearly with pi depth
Out of scope
- Reorganising the existing 4-component constants. Those stay as the depth-0 path -- no behavioural change for callers that ask for <=4 components.
- New constants beyond what was shipped in Phase E.1.
Related
- Today's 4-component cap: `include/sw/universal/number/elreal/math/constants/elreal_constants.hpp`
- Reference: Bailey-Borwein-Plouffe 1997 "On the rapid computation of various polylogarithmic constants"
Part of #903. Extends the math constants from the 4-component (~ 212-bit) ceiling to arbitrary precision on demand.
Scope
Phase E.1 (#887, PR #893) shipped `elreal_pi`, `elreal_e`, `elreal_ln2`, `elreal_ln10`, `elreal_sqrt2`, `elreal_sqrt3`, `elreal_phi`, plus pi multiples / fractions. All are built from the precomputed 4-component expansions in `qd_constants.hpp`, capping the constants at ~ 212 bits. This phase replaces the 4-component fallback with on-demand-deeper computation.
Deliverables
O.1 BBP-style pi extraction
The Bailey-Borwein-Plouffe formula computes the n-th hexadecimal digit of pi directly, without computing the preceding digits. The lazy generator at depth k pulls 4*k more hex digits (a constant amount of work per depth step). Wire this into `elreal_pi` so the existing 4-component leading expansion remains the depth-0 path and the BBP generator kicks in for k >= 4.
O.2 Taylor truncation for e
The exp(1) series converges fast. Each additional term doubles the precision. Wire as a generator on `elreal_e`.
O.3 Taylor truncation for ln2 / ln10
`ln(1 + x)` Taylor on a small-residual argument. The same approach extends to `ln10 = ln2 + ln(5)`. Wire as generators.
O.4 Newton iteration for sqrt2 / sqrt3
Reuse the Phase L Newton-sqrt generator (so this Phase is gated on Phase L).
Acceptance
Dependencies
Out of scope
Related