pub fn primitive_float_sinh<T>(x: T) -> Twhere
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float> + PrimitiveFloat,Expand description
Computes $\sinh x$, the hyperbolic sine of a primitive float. The result is correctly rounded.
$$ f(x) = \sinh x+\varepsilon. $$
- If $\sinh x$ is infinite, zero, or
NaN, $\varepsilon$ may be ignored or assumed to be 0. - If $\sinh x$ is finite and nonzero, then $|\varepsilon| < 2^{\lfloor\log_2 |\sinh
x|\rfloor-p}$, where $p$ is the precision of the output (typically 24 if
Tis af32and 53 ifTis af64, but less if the output is subnormal).
Special cases:
- $f(\text{NaN})=\text{NaN}$
- $f(\infty)=\infty$
- $f(-\infty)=-\infty$
- $f(0.0)=0.0$
- $f(-0.0)=-0.0$
Overflow is possible: a large positive x gives $\infty$, and a large negative x gives
$-\infty$. Since $|\sinh x|\geq|x|$, the result never underflows.
§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::sinh::primitive_float_sinh;
assert!(primitive_float_sinh(f32::NAN).is_nan());
assert_eq!(
NiceFloat(primitive_float_sinh(f32::INFINITY)),
NiceFloat(f32::INFINITY)
);
assert_eq!(
NiceFloat(primitive_float_sinh(f32::NEGATIVE_INFINITY)),
NiceFloat(f32::NEGATIVE_INFINITY)
);
assert_eq!(NiceFloat(primitive_float_sinh(-0.0f32)), NiceFloat(-0.0));
assert_eq!(
NiceFloat(primitive_float_sinh(1.0f32)),
NiceFloat(1.1752012)
);
assert_eq!(
NiceFloat(primitive_float_sinh(-1.0f32)),
NiceFloat(-1.1752012)
);
assert_eq!(
NiceFloat(primitive_float_sinh(-100.0f32)),
NiceFloat(f32::NEGATIVE_INFINITY)
);