Average Error: 0.1 → 0.1
Time: 9.5s
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 r686916 = x;
        double r686917 = y;
        double r686918 = z;
        double r686919 = r686917 + r686918;
        double r686920 = r686916 * r686919;
        double r686921 = 5.0;
        double r686922 = r686918 * r686921;
        double r686923 = r686920 + r686922;
        return r686923;
}

double f(double x, double y, double z) {
        double r686924 = x;
        double r686925 = y;
        double r686926 = z;
        double r686927 = r686925 + r686926;
        double r686928 = 5.0;
        double r686929 = r686926 * r686928;
        double r686930 = fma(r686924, r686927, r686929);
        return r686930;
}

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 2020042 +o rules:numerics
(FPCore (x y z)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C"
  :precision binary64

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

  (+ (* x (+ y z)) (* z 5)))