Shared Rust kernels

ported/sinh

All modules · quoted at commit 9e1884369a67 of DnaCalc/DnaCalc. Comments are the source's own.

sinh_kernel · 15 lines · calc-func/src/ported/sinh.rs on GitHub
pub fn sinh_kernel(n: f64) -> f64 {
    // W111 neighboring-bit observations distinguish the EXP difference at
    // |x| >= 1 from the cancellation-safe expm1 difference below that boundary.
    if n.abs() >= 1.0 {
        return crate::ported::excel_numeric::excel_x87_sub(
            crate::ported::excel_numeric::excel_exp(n),
            crate::ported::excel_numeric::excel_exp(-n),
        ) / 2.0;
    }
    // Live Excel 16.0 b20326 Range.Value2: SINH(x)=(expm1(x)-expm1(-x))/2
    // using Excel's internal Kahan expm1, 37/37 including the worksheet
    // EXP-pair misses at |x|<~0.25. libm sinh is 1 ULP off at 0.01 and 2.
    (crate::ported::excel_numeric::excel_expm1_internal(n) - crate::ported::excel_numeric::excel_expm1_internal(-n))
        / 2.0
}

Used by 4 functions.