Average Error: 0.1 → 0.0
Time: 15.5s
Precision: 64
\[x \cdot \left(y + z\right) + z \cdot 5.0\]
\[\mathsf{fma}\left(z, 5.0 + x, y \cdot x\right)\]
x \cdot \left(y + z\right) + z \cdot 5.0
\mathsf{fma}\left(z, 5.0 + x, y \cdot x\right)
double f(double x, double y, double z) {
        double r25484568 = x;
        double r25484569 = y;
        double r25484570 = z;
        double r25484571 = r25484569 + r25484570;
        double r25484572 = r25484568 * r25484571;
        double r25484573 = 5.0;
        double r25484574 = r25484570 * r25484573;
        double r25484575 = r25484572 + r25484574;
        return r25484575;
}

double f(double x, double y, double z) {
        double r25484576 = z;
        double r25484577 = 5.0;
        double r25484578 = x;
        double r25484579 = r25484577 + r25484578;
        double r25484580 = y;
        double r25484581 = r25484580 * r25484578;
        double r25484582 = fma(r25484576, r25484579, r25484581);
        return r25484582;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 0.1

    \[x \cdot \left(y + z\right) + z \cdot 5.0\]
  2. Simplified0.0

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

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

Reproduce

herbie shell --seed 2019164 +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)))