Average Error: 0.1 → 0.1
Time: 14.1s
Precision: 64
\[x \cdot \left(y + z\right) + z \cdot 5.0\]
\[\mathsf{fma}\left(x, z + y, z \cdot 5.0\right)\]
x \cdot \left(y + z\right) + z \cdot 5.0
\mathsf{fma}\left(x, z + y, z \cdot 5.0\right)
double f(double x, double y, double z) {
        double r19046974 = x;
        double r19046975 = y;
        double r19046976 = z;
        double r19046977 = r19046975 + r19046976;
        double r19046978 = r19046974 * r19046977;
        double r19046979 = 5.0;
        double r19046980 = r19046976 * r19046979;
        double r19046981 = r19046978 + r19046980;
        return r19046981;
}

double f(double x, double y, double z) {
        double r19046982 = x;
        double r19046983 = z;
        double r19046984 = y;
        double r19046985 = r19046983 + r19046984;
        double r19046986 = 5.0;
        double r19046987 = r19046983 * r19046986;
        double r19046988 = fma(r19046982, r19046985, r19046987);
        return r19046988;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.1
Herbie0.1
\[\left(x + 5.0\right) \cdot z + x \cdot y\]

Derivation

  1. Initial program 0.1

    \[x \cdot \left(y + z\right) + z \cdot 5.0\]
  2. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, 5.0 + x, x \cdot y\right)}\]
  3. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{5.0 \cdot z + \left(x \cdot z + x \cdot y\right)}\]
  4. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, \left(5.0 + x\right) \cdot z\right)}\]
  5. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{5.0 \cdot z + \left(x \cdot y + x \cdot z\right)}\]
  6. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, z + y, z \cdot 5.0\right)}\]
  7. Final simplification0.1

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

Reproduce

herbie shell --seed 2019163 +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)))