Average Error: 0.0 → 0
Time: 7.0s
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 r36880813 = x;
        double r36880814 = y;
        double r36880815 = 1.0;
        double r36880816 = r36880814 + r36880815;
        double r36880817 = r36880813 * r36880816;
        return r36880817;
}

double f(double x, double y) {
        double r36880818 = y;
        double r36880819 = x;
        double r36880820 = 1.0;
        double r36880821 = r36880820 * r36880819;
        double r36880822 = fma(r36880818, r36880819, r36880821);
        return r36880822;
}

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