Average Error: 0.1 → 0.1
Time: 8.0s
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 r713422 = x;
        double r713423 = y;
        double r713424 = z;
        double r713425 = r713423 + r713424;
        double r713426 = r713422 * r713425;
        double r713427 = 5.0;
        double r713428 = r713424 * r713427;
        double r713429 = r713426 + r713428;
        return r713429;
}

double f(double x, double y, double z) {
        double r713430 = x;
        double r713431 = y;
        double r713432 = z;
        double r713433 = r713431 + r713432;
        double r713434 = 5.0;
        double r713435 = r713432 * r713434;
        double r713436 = fma(r713430, r713433, r713435);
        return r713436;
}

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