Average Error: 0.1 → 0.1
Time: 9.2s
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 r668761 = x;
        double r668762 = y;
        double r668763 = z;
        double r668764 = r668762 + r668763;
        double r668765 = r668761 * r668764;
        double r668766 = 5.0;
        double r668767 = r668763 * r668766;
        double r668768 = r668765 + r668767;
        return r668768;
}

double f(double x, double y, double z) {
        double r668769 = x;
        double r668770 = y;
        double r668771 = z;
        double r668772 = r668770 + r668771;
        double r668773 = 5.0;
        double r668774 = r668771 * r668773;
        double r668775 = fma(r668769, r668772, r668774);
        return r668775;
}

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