pub fn primitive_float_asin<T>(x: T) -> Twhere
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float> + PrimitiveFloat,Expand description
Computes $\arcsin x$, the arcsine of a primitive float. Using this function is more accurate
than using the default asin function or the one provided by libm.
$$ f(x) = \arcsin x+\varepsilon. $$
- If $x$ is NaN, $\varepsilon$ may be ignored or assumed to be 0.
- If $x$ is not NaN, then $|\varepsilon| < 2^{\lfloor\log_2 |\arcsin x|\rfloor-p}$, where $p$ is
the precision of the output (24 if
Tis af32and 53 ifTis af64).
Special cases:
- $f(\text{NaN},p,m)=f(\pm\infty,p,m)=\text{NaN}$
- $f(x,p,m)=\text{NaN}$ for $|x|>1$
- $f(\pm0.0,p,m)=\pm0.0$
- $f(\pm1,p,m)=\pm\pi/2$, rounded
Neither overflow nor underflow is possible: the result lies in $[-\pi/2, \pi/2]$, and $|\arcsin x| > |x|$ for nonzero $x$, so the result is subnormal only when $x$ is, and then it is $x$ itself, since $|\arcsin x - x| < |x|^3/3$.
§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::asin::primitive_float_asin;
assert!(primitive_float_asin(f32::NAN).is_nan());
assert_eq!(
NiceFloat(primitive_float_asin(f32::INFINITY)),
NiceFloat(f32::NAN)
);
assert_eq!(
NiceFloat(primitive_float_asin(f32::NEGATIVE_INFINITY)),
NiceFloat(f32::NAN)
);
assert_eq!(NiceFloat(primitive_float_asin(0.0f32)), NiceFloat(0.0));
assert_eq!(NiceFloat(primitive_float_asin(-0.0f32)), NiceFloat(-0.0));
assert_eq!(
NiceFloat(primitive_float_asin(1.0f32)),
NiceFloat(1.5707964)
);
assert_eq!(
NiceFloat(primitive_float_asin(1.0f64)),
NiceFloat(1.5707963267948966)
);