Average Error: 0.1 → 0.1
Time: 14.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 r411081 = x;
        double r411082 = y;
        double r411083 = z;
        double r411084 = r411082 + r411083;
        double r411085 = r411081 * r411084;
        double r411086 = 5.0;
        double r411087 = r411083 * r411086;
        double r411088 = r411085 + r411087;
        return r411088;
}

double f(double x, double y, double z) {
        double r411089 = x;
        double r411090 = y;
        double r411091 = z;
        double r411092 = r411090 + r411091;
        double r411093 = 5.0;
        double r411094 = r411091 * r411093;
        double r411095 = fma(r411089, r411092, r411094);
        return r411095;
}

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