pub fn primitive_float_acsch<T>(x: T) -> Twhere
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float> + PrimitiveFloat,Expand description
Computes $\operatorname{acsch} x$, the inverse hyperbolic cosecant of a primitive float. Using
this function is more accurate than using the default acsch function or the one provided by
libm.
$$ f(x) = \operatorname{acsch} x+\varepsilon. $$
- If $\operatorname{acsch} x$ is infinite, zero, or NaN, $\varepsilon$ may be ignored or assumed to be 0.
- If $\operatorname{acsch} x$ is finite and nonzero, then $|\varepsilon| < 2^{\lfloor\log_2
|\operatorname{acsch} x|\rfloor-p}$, where $p$ is the precision of the output (24 if
Tis af32and 53 ifTis af64).
Special cases:
- $f(\text{NaN})=\text{NaN}$
- $f(\infty)=0.0$
- $f(-\infty)=-0.0$
- $f(0.0)=\infty$
- $f(-0.0)=-\infty$
Overflow is not possible. The result is subnormal only when $x$ is, and then it is $x$ itself, since $|\operatorname{acsch} x - x| < |x|^3/2$.
§Worst-case complexity
Constant time and additional memory.
§Examples
use malachite_base::num::basic::traits::NegativeInfinity;
use malachite_base::num::float::NiceFloat;
use malachite_float::float::arithmetic::acsch::primitive_float_acsch;
assert!(primitive_float_acsch(f32::NAN).is_nan());
assert_eq!(
NiceFloat(primitive_float_acsch(f32::INFINITY)),
NiceFloat(0.0)
);
assert_eq!(
NiceFloat(primitive_float_acsch(f32::NEGATIVE_INFINITY)),
NiceFloat(-0.0)
);
assert_eq!(
NiceFloat(primitive_float_acsch(0.0f32)),
NiceFloat(f32::INFINITY)
);
assert_eq!(
NiceFloat(primitive_float_acsch(-0.0f32)),
NiceFloat(f32::NEGATIVE_INFINITY)
);
assert_eq!(
NiceFloat(primitive_float_acsch(2.0f32)),
NiceFloat(0.4812118)
);
assert_eq!(
NiceFloat(primitive_float_acsch(2.0f64)),
NiceFloat(0.48121182505960347)
);
assert_eq!(
NiceFloat(primitive_float_acsch(-0.5f64)),
NiceFloat(-1.4436354751788103)
);