Skip to main content

primitive_float_sub_mul_rational

Function primitive_float_sub_mul_rational 

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

Subtracts the product of a primitive float and a Rational from another primitive float, with a single rounding, using emulated Float arithmetic.

The Rational multiplicand enters the product exactly, and the result is the true value of $x-yz$ rounded once to the nearest representable value.

§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 z.significant_bits().

§Examples

use core::f64::consts::{E, PI};
use malachite_base::num::float::NiceFloat;
use malachite_float::float::arithmetic::sub_mul::*;
use malachite_q::Rational;

assert_eq!(
    NiceFloat(primitive_float_sub_mul_rational(
        PI,
        E,
        &Rational::from_signeds(22, 7)
    )),
    NiceFloat(-5.401578807281491)
);