1use super::{exp, expm1, k_expo2};
2
3#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
9pub fn cosh(mut x: f64) -> f64 {
10 let mut ix = x.to_bits();
12 ix &= 0x7fffffffffffffff;
13 x = f64::from_bits(ix);
14 let w = ix >> 32;
15
16 if w < 0x3fe62e42 {
18 if w < 0x3ff00000 - (26 << 20) {
19 let x1p120 = f64::from_bits(0x4770000000000000);
20 force_eval!(x + x1p120);
21 return 1.;
22 }
23 let t = expm1(x); return 1. + t * t / (2. * (1. + t));
25 }
26
27 if w < 0x40862e42 {
29 let t = exp(x);
30 return 0.5 * (t + 1. / t);
32 }
33
34 k_expo2(x)
36}