Average Error: 5.2 → 5.2
Time: 12.6s
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 r20060029 = x;
        double r20060030 = 1.0;
        double r20060031 = y;
        double r20060032 = r20060031 * r20060031;
        double r20060033 = r20060030 + r20060032;
        double r20060034 = r20060029 * r20060033;
        return r20060034;
}

double f(double x, double y) {
        double r20060035 = y;
        double r20060036 = 1.0;
        double r20060037 = fma(r20060035, r20060035, r20060036);
        double r20060038 = x;
        double r20060039 = r20060037 * r20060038;
        return r20060039;
}

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 2019169 +o rules:numerics
(FPCore (x y)
  :name "Numeric.Integration.TanhSinh:everywhere from integration-0.2.1"

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

  (* x (+ 1.0 (* y y))))