Average Error: 0.1 → 0.1
Time: 12.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 r407832 = x;
        double r407833 = y;
        double r407834 = z;
        double r407835 = r407833 + r407834;
        double r407836 = r407832 * r407835;
        double r407837 = 5.0;
        double r407838 = r407834 * r407837;
        double r407839 = r407836 + r407838;
        return r407839;
}

double f(double x, double y, double z) {
        double r407840 = x;
        double r407841 = y;
        double r407842 = z;
        double r407843 = r407841 + r407842;
        double r407844 = 5.0;
        double r407845 = r407842 * r407844;
        double r407846 = fma(r407840, r407843, r407845);
        return r407846;
}

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