Shunyaya Symbolic Mathematical Hardware – Reference Knobs, Error Budgeting & Python (9.4–9.6)

9.4 — Reference knobs (defaults)
Numerical. eps_a = 1e-6, eps_w = 1e-12, denom_soft_min = 1e-9 (only if division_policy != strict).
Policies. division_policy in {strict, soft, meadow} (magnitude/value lane only).
Bands. Thresholds for A++/A+/A0/A-/A-- (monotone, non-overlapping).
Weights. w_i := |m_i|^gamma with default gamma = 1.
Canonical zero. Display (0,+1) when m == 0.
Parity. Always preserve phi((m,a)) = m.


9.5 — Error budgeting (first-order)
• If rapidity is quantized with step delta_u, then near u ≈ 0, |delta_a| <= |delta_u|.
• Choose band_step >= 4*|delta_a| to avoid flicker around thresholds (hysteresis can further stabilize).
• For fixed-point rapidity, size scale so |delta_a| near zero is well below your smallest band increment.


9.6 — Drop-in implementation — Python (reference-precise)
from math import atanh, tanh
EPS_A = 1e-6
EPS_W = 1e-12

def clamp_a(a, eps_a=EPS_A):
 return max(-1.0+eps_a, min(1.0-eps_a, a))

def a_mul(a1, a2, eps_a=EPS_A):
 return tanh(atanh(clamp_a(a1,eps_a)) + atanh(clamp_a(a2,eps_a)))

def a_div(af, ag, eps_a=EPS_A):
 return tanh(atanh(clamp_a(af,eps_a)) – atanh(clamp_a(ag,eps_a)))

def uw_accum(U, W, a, w=1.0, eps_a=EPS_A):
 return U + w*atanh(clamp_a(a,eps_a)), W + w

def uw_flush(U, W, eps_w=EPS_W):
 return tanh(U / max(W, eps_w))

def a_env(a_op, g_t, eps_a=EPS_A):
 return clamp_a(g_t * a_op, eps_a)

def collapse(m, a): # phi((m,a)) = m
 return m

“”” sanity checks (calculator-fast) “””
assert abs(a_mul(0.8,0.2) – ((0.8+0.2)/(1+0.8*0.2))) < 1e-12
U=W=0.0
for a in [0.2,0.5,-0.3]:
 U,W = uw_accum(U,W,a)
a_out1 = uw_flush(U,W)
U=W=0.0
for a in [-0.3,0.2,0.5]:
 U,W = uw_accum(U,W,a)
a_out2 = uw_flush(U,W)
assert abs(a_out1 – a_out2) < 1e-12


Navigation
Back: Shunyaya Symbolic Mathematical Hardware – Software Reference: Minimal API & Quickstart (9.1–9.3)
Next: Shunyaya Symbolic Mathematical Hardware – Software Reference: C, Rust & Unit Tests (9.7–9.9)


Directory of Pages
SSMH – Table of Contents