Average Error: 5.8 → 5.8
Time: 13.7s
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 r298221 = x;
        double r298222 = 1.0;
        double r298223 = y;
        double r298224 = r298223 * r298223;
        double r298225 = r298222 + r298224;
        double r298226 = r298221 * r298225;
        return r298226;
}

double f(double x, double y) {
        double r298227 = y;
        double r298228 = 1.0;
        double r298229 = fma(r298227, r298227, r298228);
        double r298230 = x;
        double r298231 = r298229 * r298230;
        return r298231;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 5.8

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

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

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

Reproduce

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