Average Error: 0.1 → 0.1
Time: 8.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 r57712 = x;
        double r57713 = 1.0;
        double r57714 = y;
        double r57715 = r57712 * r57714;
        double r57716 = r57713 - r57715;
        double r57717 = r57712 * r57716;
        return r57717;
}

double f(double x, double y) {
        double r57718 = x;
        double r57719 = y;
        double r57720 = -r57719;
        double r57721 = 1.0;
        double r57722 = fma(r57718, r57720, r57721);
        double r57723 = r57718 * r57722;
        return r57723;
}

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))))