Average Error: 5.2 → 5.2
Time: 9.0s
Precision: 64
\[x \cdot \left(1 + y \cdot y\right)\]
\[\mathsf{fma}\left(y, y, 1\right) \cdot x\]
x \cdot \left(1 + y \cdot y\right)
\mathsf{fma}\left(y, y, 1\right) \cdot x
double f(double x, double y) {
        double r298488 = x;
        double r298489 = 1.0;
        double r298490 = y;
        double r298491 = r298490 * r298490;
        double r298492 = r298489 + r298491;
        double r298493 = r298488 * r298492;
        return r298493;
}

double f(double x, double y) {
        double r298494 = y;
        double r298495 = 1.0;
        double r298496 = fma(r298494, r298494, r298495);
        double r298497 = x;
        double r298498 = r298496 * r298497;
        return r298498;
}

Error

Bits error versus x

Bits error versus y

Target

Original5.2
Target0.1
Herbie5.2
\[x + \left(x \cdot y\right) \cdot y\]

Derivation

  1. Initial program 5.2

    \[x \cdot \left(1 + y \cdot y\right)\]
  2. Simplified5.2

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

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

Reproduce

herbie shell --seed 2019209 +o rules:numerics
(FPCore (x y)
  :name "Numeric.Integration.TanhSinh:everywhere from integration-0.2.1"
  :precision binary64

  :herbie-target
  (+ x (* (* x y) y))

  (* x (+ 1 (* y y))))