Average Error: 0.1 → 0.1
Time: 11.5s
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 r600950 = x;
        double r600951 = y;
        double r600952 = z;
        double r600953 = r600951 + r600952;
        double r600954 = r600950 * r600953;
        double r600955 = 5.0;
        double r600956 = r600952 * r600955;
        double r600957 = r600954 + r600956;
        return r600957;
}

double f(double x, double y, double z) {
        double r600958 = x;
        double r600959 = y;
        double r600960 = z;
        double r600961 = r600959 + r600960;
        double r600962 = 5.0;
        double r600963 = r600960 * r600962;
        double r600964 = fma(r600958, r600961, r600963);
        return r600964;
}

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