Average Error: 0.1 → 0.0
Time: 13.2s
Precision: 64
\[x \cdot \left(y + z\right) + z \cdot 5\]
\[\mathsf{fma}\left(z, 5 + x, y \cdot x\right)\]
x \cdot \left(y + z\right) + z \cdot 5
\mathsf{fma}\left(z, 5 + x, y \cdot x\right)
double f(double x, double y, double z) {
        double r28778724 = x;
        double r28778725 = y;
        double r28778726 = z;
        double r28778727 = r28778725 + r28778726;
        double r28778728 = r28778724 * r28778727;
        double r28778729 = 5.0;
        double r28778730 = r28778726 * r28778729;
        double r28778731 = r28778728 + r28778730;
        return r28778731;
}

double f(double x, double y, double z) {
        double r28778732 = z;
        double r28778733 = 5.0;
        double r28778734 = x;
        double r28778735 = r28778733 + r28778734;
        double r28778736 = y;
        double r28778737 = r28778736 * r28778734;
        double r28778738 = fma(r28778732, r28778735, r28778737);
        return r28778738;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.1
Herbie0.0
\[\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.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, 5 + x, x \cdot y\right)}\]
  3. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(z, 5 + x, y \cdot x\right)\]

Reproduce

herbie shell --seed 2019170 +o rules:numerics
(FPCore (x y z)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C"

  :herbie-target
  (+ (* (+ x 5.0) z) (* x y))

  (+ (* x (+ y z)) (* z 5.0)))