Average Error: 5.3 → 5.3
Time: 11.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 r27884101 = x;
        double r27884102 = 1.0;
        double r27884103 = y;
        double r27884104 = r27884103 * r27884103;
        double r27884105 = r27884102 + r27884104;
        double r27884106 = r27884101 * r27884105;
        return r27884106;
}

double f(double x, double y) {
        double r27884107 = y;
        double r27884108 = 1.0;
        double r27884109 = fma(r27884107, r27884107, r27884108);
        double r27884110 = x;
        double r27884111 = r27884109 * r27884110;
        return r27884111;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 5.3

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

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

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

Reproduce

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