Average Error: 0.1 → 0.1
Time: 7.8s
Precision: 64
\[x \cdot \left(1 - x \cdot y\right)\]
\[x \cdot \mathsf{fma}\left(-x, y, 1\right)\]
x \cdot \left(1 - x \cdot y\right)
x \cdot \mathsf{fma}\left(-x, y, 1\right)
double f(double x, double y) {
        double r70749 = x;
        double r70750 = 1.0;
        double r70751 = y;
        double r70752 = r70749 * r70751;
        double r70753 = r70750 - r70752;
        double r70754 = r70749 * r70753;
        return r70754;
}

double f(double x, double y) {
        double r70755 = x;
        double r70756 = -r70755;
        double r70757 = y;
        double r70758 = 1.0;
        double r70759 = fma(r70756, r70757, r70758);
        double r70760 = r70755 * r70759;
        return r70760;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Initial program 0.1

    \[x \cdot \left(1 - x \cdot y\right)\]
  2. Taylor expanded around 0 0.1

    \[\leadsto x \cdot \color{blue}{\left(1 - x \cdot y\right)}\]
  3. Simplified0.1

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

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

Reproduce

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