pub fn primitive_float_acot_rational<T>(x: &Rational) -> TExpand description
Computes $\operatorname{acot} x$, the arccotangent of a Rational, 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 output type.
Special cases:
- $f(0)=\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$. The result is subnormal, or zero, only when $|x|$ is large enough to put $1/|x|$ below the bottom of the output type’s 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::basic::traits::{NegativeOne, One, Two, Zero};
use malachite_base::num::float::NiceFloat;
use malachite_float::float::arithmetic::acot::primitive_float_acot_rational;
use malachite_q::Rational;
// an input of zero gives pi/2
assert_eq!(
NiceFloat(primitive_float_acot_rational::<f64>(&Rational::ZERO)),
NiceFloat(core::f64::consts::FRAC_PI_2)
);
assert_eq!(
NiceFloat(primitive_float_acot_rational::<f64>(&Rational::ONE)),
NiceFloat(0.7853981633974483)
);
assert_eq!(
NiceFloat(primitive_float_acot_rational::<f64>(
&Rational::NEGATIVE_ONE
)),
NiceFloat(-0.7853981633974483)
);
assert_eq!(
NiceFloat(primitive_float_acot_rational::<f64>(&Rational::TWO)),
NiceFloat(0.4636476090008061)
);
assert_eq!(
NiceFloat(primitive_float_acot_rational::<f32>(
&Rational::from_unsigneds(5u8, 3)
)),
NiceFloat(0.5404195)
);