Average Error: 5.4 → 5.4
Time: 12.4s
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 r21030999 = x;
        double r21031000 = 1.0;
        double r21031001 = y;
        double r21031002 = r21031001 * r21031001;
        double r21031003 = r21031000 + r21031002;
        double r21031004 = r21030999 * r21031003;
        return r21031004;
}

double f(double x, double y) {
        double r21031005 = y;
        double r21031006 = 1.0;
        double r21031007 = fma(r21031005, r21031005, r21031006);
        double r21031008 = x;
        double r21031009 = r21031007 * r21031008;
        return r21031009;
}

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

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

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

Reproduce

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