Average Error: 5.7 → 5.7
Time: 13.4s
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 r366146 = x;
        double r366147 = 1.0;
        double r366148 = y;
        double r366149 = r366148 * r366148;
        double r366150 = r366147 + r366149;
        double r366151 = r366146 * r366150;
        return r366151;
}

double f(double x, double y) {
        double r366152 = y;
        double r366153 = 1.0;
        double r366154 = fma(r366152, r366152, r366153);
        double r366155 = x;
        double r366156 = r366154 * r366155;
        return r366156;
}

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 2019305 +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))))