Average Error: 5.4 → 5.4
Time: 14.9s
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 r331644 = x;
        double r331645 = 1.0;
        double r331646 = y;
        double r331647 = r331646 * r331646;
        double r331648 = r331645 + r331647;
        double r331649 = r331644 * r331648;
        return r331649;
}

double f(double x, double y) {
        double r331650 = y;
        double r331651 = 1.0;
        double r331652 = fma(r331650, r331650, r331651);
        double r331653 = x;
        double r331654 = r331652 * r331653;
        return r331654;
}

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 2019323 +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))))