Average Error: 0.1 → 0.1
Time: 32.6s
Precision: 64
\[x \cdot \left(y + z\right) + z \cdot 5\]
\[\mathsf{fma}\left(y + z, x, 5 \cdot z\right)\]
x \cdot \left(y + z\right) + z \cdot 5
\mathsf{fma}\left(y + z, x, 5 \cdot z\right)
double f(double x, double y, double z) {
        double r24708562 = x;
        double r24708563 = y;
        double r24708564 = z;
        double r24708565 = r24708563 + r24708564;
        double r24708566 = r24708562 * r24708565;
        double r24708567 = 5.0;
        double r24708568 = r24708564 * r24708567;
        double r24708569 = r24708566 + r24708568;
        return r24708569;
}

double f(double x, double y, double z) {
        double r24708570 = y;
        double r24708571 = z;
        double r24708572 = r24708570 + r24708571;
        double r24708573 = x;
        double r24708574 = 5.0;
        double r24708575 = r24708574 * r24708571;
        double r24708576 = fma(r24708572, r24708573, r24708575);
        return r24708576;
}

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.0

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

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

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

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

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

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

Reproduce

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