Skip to content

elreal Phase E: Mathematical functions #878

@Ravenwater

Description

@Ravenwater

Part of #873. Blocked by Phase D.

Scope

The standard transcendental and root families, lazily implemented.

Sub-issues

Phase E is broken into 6 family-grouped sub-issues to keep PRs review-sized:

Deliverables (per sub-issue)

  • sqrt, hypot (E.2)
  • exp, log, exp2, log2, log10, expm1, log1p, pow (E.3)
  • sin, cos, tan (E.6); asin, acos, atan, atan2 (E.5)
  • sinh, cosh, tanh, asinh, acosh, atanh (E.4)
  • Math constants pi, e, ln2, ln10 wired into numeric_limits<elreal> (E.1)
  • Tests under elastic/elreal/math/*.cpp (test scaffolding from elastic/ereal/math/functions/ is the natural starting point)

Algorithmic notes

  • Roots and the exp/log family are well-suited to lazy refinement (Newton, Taylor with adaptive truncation, AGM for log).
  • Trig is the hard case: range reduction in exact arithmetic requires pulling arbitrarily many bits of pi. Document the strategy (e.g., Payne-Hanek with on-demand pi refinement).
  • numeric_limits<elreal>::pi() etc. should themselves return elreal values (lazy streams of pi), not pre-rounded doubles.

Acceptance (Phase E as a whole)

  • Each function passes round-trip identity tests at the refinement target (exp(log(x)) ~= x, sin^2 + cos^2 ~= 1, ...)
  • Cross-validation against ereal::exp etc. at matched precision targets
  • Range-reduction strategy for trig documented in a header comment

Dependency graph

E.1 (constants)
   |
   +-- E.3 (exp/log/pow)
   |       |
   |       +-- E.4 (hyperbolic)
   |
   +-- E.6 (forward trig, hardest)
   |
   +-- E.5 (inverse trig, also needs E.2 for sqrt)

E.2 (sqrt + hypot) -- independent

Metadata

Metadata

Assignees

No fields configured for Feature.

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions