pub fn primitive_float_root_s<T>(x: T, k: i64) -> Twhere
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float> + PrimitiveFloat,Expand description
Takes the $k$th root of a primitive float, where $k$ may be negative. The result is correctly rounded.
$$ f(x,k) = \sqrt[k]{x}+\varepsilon. $$
- If $\sqrt[k]{x}$ is infinite, zero, or
NaN, $\varepsilon$ may be ignored or assumed to be 0. - If $\sqrt[k]{x}$ is finite and nonzero, then $|\varepsilon| < 2^{\lfloor\log_2
|\sqrt[k]{x}|\rfloor-p}$, where $p$ is the precision of the output (typically 24 if
Tis af32and 53 ifTis af64, but less if the output is subnormal).
Special cases: see Float::root_s_prec_round.
§Worst-case complexity
$T(n) = O(n^{3/2} \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the precision of the output.
§Examples
use malachite_base::num::float::NiceFloat;
use malachite_float::float::arithmetic::root::primitive_float_root_s;
assert_eq!(
NiceFloat(primitive_float_root_s(8.0f64, -3)),
NiceFloat(0.5)
);
assert_eq!(
NiceFloat(primitive_float_root_s(2.0f64, -3)),
NiceFloat(0.7937005259840998)
);