Average Error: 0.1 → 0.1
Time: 15.1s
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 r418290 = x;
        double r418291 = y;
        double r418292 = z;
        double r418293 = r418291 + r418292;
        double r418294 = r418290 * r418293;
        double r418295 = 5.0;
        double r418296 = r418292 * r418295;
        double r418297 = r418294 + r418296;
        return r418297;
}

double f(double x, double y, double z) {
        double r418298 = x;
        double r418299 = y;
        double r418300 = z;
        double r418301 = r418299 + r418300;
        double r418302 = 5.0;
        double r418303 = r418300 * r418302;
        double r418304 = fma(r418298, r418301, r418303);
        return r418304;
}

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