Average Error: 5.7 → 5.7
Time: 12.9s
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 r330419 = x;
        double r330420 = 1.0;
        double r330421 = y;
        double r330422 = r330421 * r330421;
        double r330423 = r330420 + r330422;
        double r330424 = r330419 * r330423;
        return r330424;
}

double f(double x, double y) {
        double r330425 = y;
        double r330426 = 1.0;
        double r330427 = fma(r330425, r330425, r330426);
        double r330428 = x;
        double r330429 = r330427 * r330428;
        return r330429;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 5.7

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

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

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

Reproduce

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