Skip to main content

ERR_COEFF_2

Constant ERR_COEFF_2 

Source
pub const ERR_COEFF_2: f64 = _; // 6.6613381477509471E-16f64
Expand description

Absolute error coefficient for Matrix::<2>::det_direct.

This constant is not a caller-tuned tolerance. It is the dimension-specific multiplier that turns the matrix’s absolute Leibniz sum into a conservative bound on floating-point roundoff in the closed-form 2×2 determinant formula.

For any 2×2 matrix A = [[a, b], [c, d]] with finite f64 entries,

|A.det_direct() - det_exact(A)|  ≤  ERR_COEFF_2 · (|a·d| + |b·c|)

det_direct evaluates a·d - b·c as one multiply followed by one FMA (2 rounding events); the linear 3·EPS term bounds those roundings and the quadratic 16·EPS² term is a conservative cushion for their interaction. Derivation follows Shewchuk’s framework; see REFERENCES.md [8].

Prefer Matrix::det_errbound unless you already have the absolute-Leibniz sum available; see Matrix::det_sign_exact (under the exact feature) for the reference adaptive-precision filter.

§Example

use la_stack::prelude::*;

let m = Matrix::<2>::try_from_rows([[1.0, 2.0], [3.0, 4.0]])?;
let Some(det) = m.det_direct()? else {
    return Ok(());
};
assert_eq!(det, -2.0);
// Compute the bound from the raw constant for illustration; most
// callers would match on `m.det_errbound()?` instead.
let p = (1.0_f64 * 4.0).abs() + (2.0_f64 * 3.0).abs();
let bound = ERR_COEFF_2 * p;
if det.abs() > bound {
    // The f64 sign is provably correct without exact arithmetic.
}