Average Error: 4.8 → 4.8
Time: 13.3s
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 r21645014 = x;
        double r21645015 = 1.0;
        double r21645016 = y;
        double r21645017 = r21645016 * r21645016;
        double r21645018 = r21645015 + r21645017;
        double r21645019 = r21645014 * r21645018;
        return r21645019;
}

double f(double x, double y) {
        double r21645020 = y;
        double r21645021 = 1.0;
        double r21645022 = fma(r21645020, r21645020, r21645021);
        double r21645023 = x;
        double r21645024 = r21645022 * r21645023;
        return r21645024;
}

Error

Bits error versus x

Bits error versus y

Target

Original4.8
Target0.1
Herbie4.8
\[x + \left(x \cdot y\right) \cdot y\]

Derivation

  1. Initial program 4.8

    \[x \cdot \left(1.0 + y \cdot y\right)\]
  2. Simplified4.8

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

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

Reproduce

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