Average Error: 0.1 → 0.1
Time: 11.6s
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 r638578 = x;
        double r638579 = y;
        double r638580 = z;
        double r638581 = r638579 + r638580;
        double r638582 = r638578 * r638581;
        double r638583 = 5.0;
        double r638584 = r638580 * r638583;
        double r638585 = r638582 + r638584;
        return r638585;
}

double f(double x, double y, double z) {
        double r638586 = x;
        double r638587 = y;
        double r638588 = z;
        double r638589 = r638587 + r638588;
        double r638590 = 5.0;
        double r638591 = r638588 * r638590;
        double r638592 = fma(r638586, r638589, r638591);
        return r638592;
}

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