Average Error: 5.4 → 5.4
Time: 12.5s
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 r20760614 = x;
        double r20760615 = 1.0;
        double r20760616 = y;
        double r20760617 = r20760616 * r20760616;
        double r20760618 = r20760615 + r20760617;
        double r20760619 = r20760614 * r20760618;
        return r20760619;
}

double f(double x, double y) {
        double r20760620 = y;
        double r20760621 = 1.0;
        double r20760622 = fma(r20760620, r20760620, r20760621);
        double r20760623 = x;
        double r20760624 = r20760622 * r20760623;
        return r20760624;
}

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