Average Error: 5.8 → 5.8
Time: 13.1s
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 r352487 = x;
        double r352488 = 1.0;
        double r352489 = y;
        double r352490 = r352489 * r352489;
        double r352491 = r352488 + r352490;
        double r352492 = r352487 * r352491;
        return r352492;
}

double f(double x, double y) {
        double r352493 = y;
        double r352494 = 1.0;
        double r352495 = fma(r352493, r352493, r352494);
        double r352496 = x;
        double r352497 = r352495 * r352496;
        return r352497;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 5.8

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

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

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

Reproduce

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