Average Error: 5.0 → 5.0
Time: 9.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 r514406 = x;
        double r514407 = 1.0;
        double r514408 = y;
        double r514409 = r514408 * r514408;
        double r514410 = r514407 + r514409;
        double r514411 = r514406 * r514410;
        return r514411;
}

double f(double x, double y) {
        double r514412 = y;
        double r514413 = 1.0;
        double r514414 = fma(r514412, r514412, r514413);
        double r514415 = x;
        double r514416 = r514414 * r514415;
        return r514416;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 5.0

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

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

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

Reproduce

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