Some checks are pending
docs / build-and-deploy (push) Waiting to run
Finish the unblocked "Math / Ease" half of #25: the fixed-point transcendentals deferred from #2. Vec.* stays blocked on the vec2 type in #1. - Math.exp, Math.log (natural), Math.pow — deterministic Q16.16 via two new prelude fns in emit_math_prelude: @fn_fx_exp2 (range-reduced 5th-order Taylor 2^f, then a clamped shift by the integer part) and @fn_fx_log2 (llvm.ctlz for the exponent + an atanh series on (m-1)/(m+1) for the mantissa). exp=2^(x·log2 e), log=log2(x)·ln2, pow=2^(b·log2 a). - Ease.elastic — ease-out elastic 2^(-10t)·sin((10t-0.75)·2pi/3)+1. - Pure integer IR, so bit-identical on every platform. Results must fit the Q16.16 range (|x| < 32768); larger magnitudes saturate (documented). Test selfhost/tests/transcend.ludic (registered in the self-host suite) + docs for all four. Reseeded; the C-free bootstrap fixpoint holds. All suites green (24 self-host, 45 regression, 29 tool). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
22 lines
900 B
Markdown
22 lines
900 B
Markdown
---
|
|
id: math-exp
|
|
name: Math.exp
|
|
category: math
|
|
kind: namespace-method
|
|
tokens: Math.exp
|
|
sig: Math.exp(x) -> fixed
|
|
tip: e raised to the power x.
|
|
order: 29
|
|
ns: Math
|
|
member: exp
|
|
---
|
|
|
|
Returns <code>e<sup>x</sup></code> (the natural exponential), computed in Q16.16 as <code>2<sup>x·log₂e</sup></code> through a range-reduced integer polynomial — so it is bit-identical on every platform, the same guarantee the rest of the runtime gives. Pair it with <code>Math.log</code> for exponential decay and growth: cooldowns that ease off, difficulty ramps, or a value that relaxes toward a target. The result must land inside the fixed-point range (magnitudes below <code>32768</code>), so keep <code>x</code> under about <code>10</code>; larger exponents saturate.
|
|
|
|
```ludic
|
|
program Demo {
|
|
handler Step phase Update {
|
|
let remaining = Math.exp(0.0 - decay * elapsed) # smooth decay 1 -> 0
|
|
}
|
|
}
|
|
```
|