Skip to main content

primitive_float_cbrt_rational

Function primitive_float_cbrt_rational 

Source
pub fn primitive_float_cbrt_rational<T>(x: &Rational) -> T
where Float: PartialOrd<T>, for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float> + PrimitiveFloat,
Expand description

Takes the cube root of a Rational, returning a correctly-rounded primitive float.

The returned primitive float is the one closest to the real cube root of the input, with ties rounded to even.

$$ f(x) = \sqrt[3]{x}. $$

§Worst-case complexity

$T(n) = O(n \log n \log\log n)$

$M(n) = O(n \log n)$

where $T$ is time, $M$ is additional memory, and $n$ is x.significant_bits().

§Examples

use malachite_float::float::arithmetic::cbrt::primitive_float_cbrt_rational;
use malachite_q::Rational;

assert_eq!(
    primitive_float_cbrt_rational::<f64>(&Rational::from(27)),
    3.0
);
assert_eq!(
    primitive_float_cbrt_rational::<f64>(&Rational::from(-8)),
    -2.0
);