Average Error: 0.1 → 0.1
Time: 14.8s
Precision: 64
\[x \cdot \left(y + z\right) + z \cdot 5\]
\[\mathsf{fma}\left(x, y + z, z \cdot 5\right)\]
x \cdot \left(y + z\right) + z \cdot 5
\mathsf{fma}\left(x, y + z, z \cdot 5\right)
double f(double x, double y, double z) {
        double r354992 = x;
        double r354993 = y;
        double r354994 = z;
        double r354995 = r354993 + r354994;
        double r354996 = r354992 * r354995;
        double r354997 = 5.0;
        double r354998 = r354994 * r354997;
        double r354999 = r354996 + r354998;
        return r354999;
}

double f(double x, double y, double z) {
        double r355000 = x;
        double r355001 = y;
        double r355002 = z;
        double r355003 = r355001 + r355002;
        double r355004 = 5.0;
        double r355005 = r355002 * r355004;
        double r355006 = fma(r355000, r355003, r355005);
        return r355006;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.1
Herbie0.1
\[\left(x + 5\right) \cdot z + x \cdot y\]

Derivation

  1. Initial program 0.1

    \[x \cdot \left(y + z\right) + z \cdot 5\]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, y + z, z \cdot 5\right)}\]
  3. Final simplification0.1

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

Reproduce

herbie shell --seed 2019199 +o rules:numerics
(FPCore (x y z)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C"

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

  (+ (* x (+ y z)) (* z 5.0)))