Average Error: 0.1 → 0.1
Time: 13.5s
Precision: 64
\[x \cdot \left(1 - x \cdot y\right)\]
\[\mathsf{fma}\left(x, -y, 1\right) \cdot x\]
x \cdot \left(1 - x \cdot y\right)
\mathsf{fma}\left(x, -y, 1\right) \cdot x
double f(double x, double y) {
        double r77673 = x;
        double r77674 = 1.0;
        double r77675 = y;
        double r77676 = r77673 * r77675;
        double r77677 = r77674 - r77676;
        double r77678 = r77673 * r77677;
        return r77678;
}

double f(double x, double y) {
        double r77679 = x;
        double r77680 = y;
        double r77681 = -r77680;
        double r77682 = 1.0;
        double r77683 = fma(r77679, r77681, r77682);
        double r77684 = r77683 * r77679;
        return r77684;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Initial program 0.1

    \[x \cdot \left(1 - x \cdot y\right)\]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, -y, 1\right) \cdot x}\]
  3. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(x, -y, 1\right) \cdot x\]

Reproduce

herbie shell --seed 2019194 +o rules:numerics
(FPCore (x y)
  :name "Numeric.SpecFunctions:log1p from math-functions-0.1.5.2, A"
  (* x (- 1.0 (* x y))))