Average Error: 0.1 → 0.1
Time: 12.7s
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 r411042 = x;
        double r411043 = y;
        double r411044 = z;
        double r411045 = r411043 + r411044;
        double r411046 = r411042 * r411045;
        double r411047 = 5.0;
        double r411048 = r411044 * r411047;
        double r411049 = r411046 + r411048;
        return r411049;
}

double f(double x, double y, double z) {
        double r411050 = x;
        double r411051 = y;
        double r411052 = z;
        double r411053 = r411051 + r411052;
        double r411054 = 5.0;
        double r411055 = r411052 * r411054;
        double r411056 = fma(r411050, r411053, r411055);
        return r411056;
}

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