pub fn primitive_float_sec_pi<T>(x: T) -> Twhere
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float> + PrimitiveFloat,Expand description
Computes $\sec(\pi x)$, the secant of a primitive float measured in half-turns.
This is primitive_float_sec_with_period with a period of 2: see
primitive_float_sec_with_period for the error bound and the special cases, with $u = 2$.
Half-integers are poles and give exactly $\infty$; even integers give exactly $1$ and odd ones
$-1$; odd multiples of $1/4$ give $\pm\sqrt2$; and multiples of $1/3$ give exactly $\pm2$.
§Worst-case complexity
Constant time and additional memory.
§Examples
use malachite_base::num::float::NiceFloat;
use malachite_float::float::arithmetic::sec::primitive_float_sec_pi;
assert!(primitive_float_sec_pi(f32::NAN).is_nan());
// a half-integer is a pole
assert_eq!(
NiceFloat(primitive_float_sec_pi(0.5f32)),
NiceFloat(f32::INFINITY)
);
// an odd integer is exactly -1
assert_eq!(NiceFloat(primitive_float_sec_pi(1.0f64)), NiceFloat(-1.0));
// an odd multiple of a quarter: sqrt(2)
assert_eq!(
NiceFloat(primitive_float_sec_pi(0.25f32)),
NiceFloat(core::f32::consts::SQRT_2)
);
assert_eq!(
NiceFloat(primitive_float_sec_pi(0.1f32)),
NiceFloat(1.0514622)
);
assert_eq!(
NiceFloat(primitive_float_sec_pi(0.1f64)),
NiceFloat(1.0514622242382672)
);