log1mexp

std.elementwise.log1mexp · Level L5

log(1 − e^(−x)) for x > 0, accurate everywhere (Mächler's rule): log(−expm1(−x)) below log 2, log1p(−e^(−x)) above. Each naive form loses its digits on one side.

x < log 2 ? log(−expm1(−x)) : log1p(−e^(−x))

Signature

log1mexp(x: f64[n]) → f64[n]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

xf64[n]0.693147NegatenxLesssmallExpm1emExpexNegatenemNegatenexLognearLog1pfarWhereyyf64[n]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Agrees with the reference log(1 − exp(−x)), in exact arithmetic to 80 digits (100-digit arithmetic), on all 40 test cases.
  • All 142 float64 results inside the running error bound; the closest uses 16% of it.
  • Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
64%
bit-equal to the NumPy formula in float64
36%
largest error, in units in the last place
2.17

Identity

Calls
—
Called by
—
sha256:2f5ca6a7684974c81dfeb099a49df15f441359e8ac26d63f4d355b88e5ba8451

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.