Average Error: 5.2 → 5.2
Time: 12.0s
Precision: 64
\[x \cdot \left(1.0 + y \cdot y\right)\]
\[\mathsf{fma}\left(y, y, 1.0\right) \cdot x\]
x \cdot \left(1.0 + y \cdot y\right)
\mathsf{fma}\left(y, y, 1.0\right) \cdot x
double f(double x, double y) {
        double r19425228 = x;
        double r19425229 = 1.0;
        double r19425230 = y;
        double r19425231 = r19425230 * r19425230;
        double r19425232 = r19425229 + r19425231;
        double r19425233 = r19425228 * r19425232;
        return r19425233;
}

double f(double x, double y) {
        double r19425234 = y;
        double r19425235 = 1.0;
        double r19425236 = fma(r19425234, r19425234, r19425235);
        double r19425237 = x;
        double r19425238 = r19425236 * r19425237;
        return r19425238;
}

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.0 + y \cdot y\right)\]
  2. Simplified5.2

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

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

Reproduce

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