pub fn primitive_float_acot<T>(x: T) -> Twhere
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float> + PrimitiveFloat,Expand description
Computes $\operatorname{acot} x$, the arccotangent of a primitive float, returning the result as a primitive float.
This is the correctly rounded arccotangent: the exact $\operatorname{acot}(x)$ is rounded once, to the nearest value of the input’s type.
Special cases:
- $f(\text{NaN})=\text{NaN}$
- $f(\infty)=0.0$ and $f(-\infty)=-0.0$
- $f(\pm0.0)=\pm\pi/2$
- $f(\pm1)=\pm\pi/4$
This is the odd arccotangent, the arctangent of the reciprocal, with range $(-\pi/2,\pi/2]$. Overflow is not possible, since $|\operatorname{acot}(x)| \leq \pi/2$, and neither is underflow: a primitive float’s exponent is bounded, so $1/|x|$ stays well inside the normal range.
§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::acot::primitive_float_acot;
assert!(primitive_float_acot(f32::NAN).is_nan());
// an input of zero gives pi/2, and one of 1 gives pi/4
assert_eq!(
NiceFloat(primitive_float_acot(0.0f32)),
NiceFloat(core::f32::consts::FRAC_PI_2)
);
assert_eq!(
NiceFloat(primitive_float_acot(1.0f32)),
NiceFloat(core::f32::consts::FRAC_PI_4)
);
assert_eq!(
NiceFloat(primitive_float_acot(f32::INFINITY)),
NiceFloat(0.0)
);
assert_eq!(
NiceFloat(primitive_float_acot(2.0f32)),
NiceFloat(0.4636476)
);
assert_eq!(
NiceFloat(primitive_float_acot(-2.0f32)),
NiceFloat(-0.4636476)
);
assert_eq!(
NiceFloat(primitive_float_acot(2.0f64)),
NiceFloat(0.4636476090008061)
);