Average Error: 5.6 → 5.6
Time: 28.0s
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 r22332500 = x;
        double r22332501 = 1.0;
        double r22332502 = y;
        double r22332503 = r22332502 * r22332502;
        double r22332504 = r22332501 + r22332503;
        double r22332505 = r22332500 * r22332504;
        return r22332505;
}

double f(double x, double y) {
        double r22332506 = y;
        double r22332507 = 1.0;
        double r22332508 = fma(r22332506, r22332506, r22332507);
        double r22332509 = x;
        double r22332510 = r22332508 * r22332509;
        return r22332510;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 5.6

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

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

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

Reproduce

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