Average Error: 0.1 → 0.1
Time: 9.8s
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 r355731 = x;
        double r355732 = y;
        double r355733 = z;
        double r355734 = r355732 + r355733;
        double r355735 = r355731 * r355734;
        double r355736 = 5.0;
        double r355737 = r355733 * r355736;
        double r355738 = r355735 + r355737;
        return r355738;
}

double f(double x, double y, double z) {
        double r355739 = x;
        double r355740 = y;
        double r355741 = z;
        double r355742 = r355740 + r355741;
        double r355743 = 5.0;
        double r355744 = r355741 * r355743;
        double r355745 = fma(r355739, r355742, r355744);
        return r355745;
}

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