module scheme import math // Recover product rounding errors only near cancellation. The C backend's // math.fma rounds each product residual once. Division retains its checks on // all four normalized products before calling this helper, keeping these // residuals in the normal range even when the final quotient is tiny. fn compensated_product_sum(a f64, b f64, c f64, d f64) f64 { p, q := a * b, c * d s := p + q if math.abs(s) < 0.01 * math.max(math.abs(p), math.abs(q)) { return s + (math.fma(a, b, -p) + math.fma(c, d, -q)) } return s }