Average Error: 0.0 → 0
Time: 6.8s
Precision: 64
\[x \cdot \left(y + 1.0\right)\]
\[\mathsf{fma}\left(y, x, 1.0 \cdot x\right)\]
x \cdot \left(y + 1.0\right)
\mathsf{fma}\left(y, x, 1.0 \cdot x\right)
double f(double x, double y) {
        double r38158241 = x;
        double r38158242 = y;
        double r38158243 = 1.0;
        double r38158244 = r38158242 + r38158243;
        double r38158245 = r38158241 * r38158244;
        return r38158245;
}

double f(double x, double y) {
        double r38158246 = y;
        double r38158247 = x;
        double r38158248 = 1.0;
        double r38158249 = r38158248 * r38158247;
        double r38158250 = fma(r38158246, r38158247, r38158249);
        return r38158250;
}

Error

Bits error versus x

Bits error versus y

Target

Original0.0
Target0.0
Herbie0
\[x + x \cdot y\]

Derivation

  1. Initial program 0.0

    \[x \cdot \left(y + 1.0\right)\]
  2. Using strategy rm
  3. Applied distribute-rgt-in0.0

    \[\leadsto \color{blue}{y \cdot x + 1.0 \cdot x}\]
  4. Using strategy rm
  5. Applied fma-def0

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

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

Reproduce

herbie shell --seed 2019162 +o rules:numerics
(FPCore (x y)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, B"

  :herbie-target
  (+ x (* x y))

  (* x (+ y 1.0)))