Average Error: 5.4 → 5.4
Time: 12.1s
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 r329373 = x;
        double r329374 = 1.0;
        double r329375 = y;
        double r329376 = r329375 * r329375;
        double r329377 = r329374 + r329376;
        double r329378 = r329373 * r329377;
        return r329378;
}

double f(double x, double y) {
        double r329379 = y;
        double r329380 = 1.0;
        double r329381 = fma(r329379, r329379, r329380);
        double r329382 = x;
        double r329383 = r329381 * r329382;
        return r329383;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 5.4

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

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

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

Reproduce

herbie shell --seed 2019235 +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))))