Context
The follow-up #41 split off. PR #124 shipped the exact group (abs, copysign, floor, ceil, round, trunc, min, max) plus sqrt. pow and log did not ship, and they are the only remaining functions that need pinned Transcendental plans.
Why these two are different from sqrt
sqrt was allowed to lower to the native instruction because IEEE-754 mandates a correctly-rounded square root — exactly one result is admissible, so every conforming target produces it and three-engine parity holds by the standard rather than by luck. Requirement 8 was amended to permit that single exception, with the reasoning stated in the spec.
No comparable mandate covers pow or log. Their results are implementation-defined, so the ban stands: no platform libm, no LLVM math intrinsic. Each needs its own pinned plan in Transcendental.ts, in the shape the Sin and Cos plans already use.
The blocker this issue inherits
#41's requirements 4–6 demand pinned reduction constants and polynomial coefficients which the issue never supplied. That is the unresolved part, and it is why this is needs-definition rather than ready:
- Which polynomial approximation, to what degree, over what reduction?
- The coefficients themselves, as exact bit values — derived how, and checked against what reference?
Transcendental.ts:3's existing Plan interface is the template: it fixes width, the canonicalNaN bit pattern, the reduction constants (inverseHalfPi, halfPi) and the sine/cosine coefficients as exact bigints, uses a fixed-order Cody-Waite reduction and Horner evaluation, and rounds every intermediate at the target width.
Decide before implementing: derive new coefficients (and say how they are validated), or adopt a published, citable set. Either is fine; guessing is not.
One lesson from PR #124 that applies directly
The correctly-rounded guarantee covers numeric results only. IEEE-754 leaves the sign of a NaN from an invalid operation unspecified, and the hosts genuinely disagree — x86 sqrt of a negative operand sets the sign bit, AArch64's default NaN clears it. PR #124 measured Wasm returning 0xFFF8000000000000 where the evaluator returned 0x7FF8000000000000, and resolved it by screening NaN and negative operands in Silk before the primitive runs.
pow and log have larger invalid domains than sqrt — negative bases with non-integer exponents, zero and negative arguments to log, and the various pow special cases. Enumerate the invalid domain explicitly and decide the result for each case, rather than discovering the disagreements one CI failure at a time.
Requirements
pow and log in f32 and f64, each with its own pinned plan.
- Each plan fixes reduction constants and polynomial coefficients as exact bit values.
- Each plan rounds every intermediate at the target width, in a fixed order.
- Neither reaches the platform
libm nor an LLVM math intrinsic — sqrt's exception does not extend to them.
- Identical bits on the evaluator, LLVM and Wasm for every input.
- The canonical NaN bit pattern for a NaN input, and a decided, tested result for every invalid-domain case.
- Amend
bootstrap-floating-point-scalars through the openspec process.
Acceptance criteria
Dependencies
None hard. #41's exact group and sqrt landed in PR #124.
Filed by orchestrator run run-r7x1 from the #41 split.
Context
The follow-up #41 split off. PR #124 shipped the exact group (
abs,copysign,floor,ceil,round,trunc,min,max) plussqrt.powandlogdid not ship, and they are the only remaining functions that need pinnedTranscendentalplans.Why these two are different from
sqrtsqrtwas allowed to lower to the native instruction because IEEE-754 mandates a correctly-rounded square root — exactly one result is admissible, so every conforming target produces it and three-engine parity holds by the standard rather than by luck. Requirement 8 was amended to permit that single exception, with the reasoning stated in the spec.No comparable mandate covers
poworlog.Their results are implementation-defined, so the ban stands: no platformlibm, no LLVM math intrinsic. Each needs its own pinned plan inTranscendental.ts, in the shape theSinandCosplans already use.The blocker this issue inherits
#41's requirements 4–6 demand pinned reduction constants and polynomial coefficients which the issue never supplied. That is the unresolved part, and it is why this is
needs-definitionrather than ready:Transcendental.ts:3's existingPlaninterface is the template: it fixes width, thecanonicalNaNbit pattern, the reduction constants (inverseHalfPi,halfPi) and thesine/cosinecoefficients as exact bigints, uses a fixed-order Cody-Waite reduction and Horner evaluation, and rounds every intermediate at the target width.Decide before implementing: derive new coefficients (and say how they are validated), or adopt a published, citable set. Either is fine; guessing is not.
One lesson from PR #124 that applies directly
The correctly-rounded guarantee covers numeric results only. IEEE-754 leaves the sign of a NaN from an invalid operation unspecified, and the hosts genuinely disagree — x86
sqrtof a negative operand sets the sign bit, AArch64's default NaN clears it. PR #124 measured Wasm returning0xFFF8000000000000where the evaluator returned0x7FF8000000000000, and resolved it by screening NaN and negative operands in Silk before the primitive runs.powandloghave larger invalid domains thansqrt— negative bases with non-integer exponents, zero and negative arguments tolog, and the variouspowspecial cases. Enumerate the invalid domain explicitly and decide the result for each case, rather than discovering the disagreements one CI failure at a time.Requirements
powandloginf32andf64, each with its own pinned plan.libmnor an LLVM math intrinsic —sqrt's exception does not extend to them.bootstrap-floating-point-scalarsthrough the openspec process.Acceptance criteria
libmor an LLVM math intrinsic.libm/intrinsic guard added by stdlib: add exact float math and a correctly rounded sqrt to f32 and f64 #124 is extended to cover them.Dependencies
None hard. #41's exact group and
sqrtlanded in PR #124.Filed by orchestrator run
run-r7x1from the #41 split.