Skip to main content

primitive_float_acsc_pi

Function primitive_float_acsc_pi 

Source
pub fn primitive_float_acsc_pi<T>(x: T) -> T
where Float: From<T> + PartialOrd<T>, for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float> + PrimitiveFloat,
Expand description

Computes $\operatorname{acsc}(x)/\pi$, the arccosecant of a primitive float measured in half-turns, returning the result as a primitive float.

This is primitive_float_acsc_with_period with a period of 2: see primitive_float_acsc_with_period for the error bounds, the special cases, and the complexity, with $u = 2$. Either infinity gives a zero of its sign, and an input of $\pm1$ gives $\pm1/2$; NaN and any $|x|<1$, including the zeros, give NaN. Overflow is not possible, since $|\operatorname{acsc}(x)/\pi| \leq 1/2$.

§Worst-case complexity

$T(m) = O(m \log m \log\log m)$

$M(m) = O(m \log m)$

where $T$ is time, $M$ is additional memory, and $m$ is x.significant_bits().

§Examples

use malachite_base::num::float::NiceFloat;
use malachite_float::float::arithmetic::acsc::primitive_float_acsc_pi;

assert!(primitive_float_acsc_pi(f32::NAN).is_nan());
// the arccosecant is NaN inside (-1, 1)
assert!(primitive_float_acsc_pi(0.5f32).is_nan());
assert_eq!(
    NiceFloat(primitive_float_acsc_pi(f32::INFINITY)),
    NiceFloat(0.0)
);
assert_eq!(NiceFloat(primitive_float_acsc_pi(1.0f32)), NiceFloat(0.5));
assert_eq!(NiceFloat(primitive_float_acsc_pi(-1.0f32)), NiceFloat(-0.5));
assert_eq!(
    NiceFloat(primitive_float_acsc_pi(2.5f32)),
    NiceFloat(0.13098988)
);
assert_eq!(
    NiceFloat(primitive_float_acsc_pi(2.5f64)),
    NiceFloat(0.13098988043445461)
);