pub fn primitive_float_cot_pi<T>(x: T) -> Twhere
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float> + PrimitiveFloat,Expand description
Computes $\cot(\pi x)$, the cotangent of a primitive float measured in half-turns.
This is primitive_float_cot_with_period with a period of 2: see
primitive_float_cot_with_period for the error bound and the special cases, with $u = 2$.
Integers are poles and give exactly $\pm\infty$, with the sign of $x$ at an even integer and the
opposite at an odd one; half-integers give exactly $\pm0.0$; odd multiples of $1/4$ give exactly
$\pm1$; odd multiples of $1/6$ give $\pm\sqrt3$; and multiples of $1/3$ that are not integers
give $\pm\sqrt3/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::cot::primitive_float_cot_pi;
assert!(primitive_float_cot_pi(f32::NAN).is_nan());
// a half-integer is exactly 0
assert_eq!(NiceFloat(primitive_float_cot_pi(0.5f32)), NiceFloat(0.0));
// an integer is a pole
assert_eq!(
NiceFloat(primitive_float_cot_pi(1.0f64)),
NiceFloat(f64::NEGATIVE_INFINITY)
);
// an odd multiple of a quarter is exactly 1
assert_eq!(NiceFloat(primitive_float_cot_pi(0.25f32)), NiceFloat(1.0));
assert_eq!(
NiceFloat(primitive_float_cot_pi(0.1f32)),
NiceFloat(3.0776834)
);
assert_eq!(
NiceFloat(primitive_float_cot_pi(0.1f64)),
NiceFloat(3.077683537175253)
);