Average Error: 5.3 → 5.3
Time: 10.8s
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 r16634416 = x;
        double r16634417 = 1.0;
        double r16634418 = y;
        double r16634419 = r16634418 * r16634418;
        double r16634420 = r16634417 + r16634419;
        double r16634421 = r16634416 * r16634420;
        return r16634421;
}

double f(double x, double y) {
        double r16634422 = y;
        double r16634423 = 1.0;
        double r16634424 = fma(r16634422, r16634422, r16634423);
        double r16634425 = x;
        double r16634426 = r16634424 * r16634425;
        return r16634426;
}

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