log_cosh

std.loss.log_cosh · Level L1

Log-cosh loss, in a form that never overflows. Calls abs.

mean( |d| + log(1 + e^(−2|d|)) − log 2 ), d = y − t

Signature

log_cosh(y: f64[n], t: f64[n]) → f64[]

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.

yf64[n]tf64[n]Subtractd2.0absadMultiplym2Negatenm21.0ExpeAddonepLogl1p0.693147AddsSubtractlcMeanllf64[]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Agrees with the reference np.mean(np.log(np.cosh(y - t))) to 80 digits (100-digit arithmetic), on all 40 test cases.
  • All 40 float64 results inside the running error bound; the closest uses 33% of it.
  • Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
40%
bit-equal to the NumPy formula in float64
38%
largest error, in units in the last place
18

Large ulp counts appear where a result is tiny next to the numbers it is computed from (after cancellation, for example), so one unit in the last place is tiny too; the absolute error is still inside the bound. Results within their own error of zero are not counted.

Note

log 2 enters as its nearest float64, so the graph equals log cosh up to that one constant's rounding; the verification accounts for it.

Identity

Calls
Called by
—
sha256:74a5472ebe8b195d84e46ea10efbdc6a8df824144fc0faf920a67c23e1d85c8c

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

Control handle

Symbol
Ω:std.loss.log_cosh · Ω:log_cosh
Pins
sha256:8287ef670a04c2cda769af27ab66327d7708b36577fad440853e282a88fe7251this graph and the 1 it reaches through calls
Evidence
sha256:e88c7c69f693f910d40889d702122cbd89c5158b46a833b863f1d38f2b3f0515the hash of its verification record
Needs
no capability: a pure function

Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.