Average Error: 4.9 → 4.9
Time: 12.3s
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 r23342639 = x;
        double r23342640 = 1.0;
        double r23342641 = y;
        double r23342642 = r23342641 * r23342641;
        double r23342643 = r23342640 + r23342642;
        double r23342644 = r23342639 * r23342643;
        return r23342644;
}

double f(double x, double y) {
        double r23342645 = y;
        double r23342646 = 1.0;
        double r23342647 = fma(r23342645, r23342645, r23342646);
        double r23342648 = x;
        double r23342649 = r23342647 * r23342648;
        return r23342649;
}

Error

Bits error versus x

Bits error versus y

Target

Original4.9
Target0.1
Herbie4.9
\[x + \left(x \cdot y\right) \cdot y\]

Derivation

  1. Initial program 4.9

    \[x \cdot \left(1.0 + y \cdot y\right)\]
  2. Simplified4.9

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

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

Reproduce

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