Average Error: 0.1 → 0.1
Time: 7.2s
Precision: 64
\[x \cdot \left(y + z\right) + z \cdot 5.0\]
\[\mathsf{fma}\left(x, y, \left(x + 5.0\right) \cdot z\right)\]
x \cdot \left(y + z\right) + z \cdot 5.0
\mathsf{fma}\left(x, y, \left(x + 5.0\right) \cdot z\right)
double f(double x, double y, double z) {
        double r9445877 = x;
        double r9445878 = y;
        double r9445879 = z;
        double r9445880 = r9445878 + r9445879;
        double r9445881 = r9445877 * r9445880;
        double r9445882 = 5.0;
        double r9445883 = r9445879 * r9445882;
        double r9445884 = r9445881 + r9445883;
        return r9445884;
}

double f(double x, double y, double z) {
        double r9445885 = x;
        double r9445886 = y;
        double r9445887 = 5.0;
        double r9445888 = r9445885 + r9445887;
        double r9445889 = z;
        double r9445890 = r9445888 * r9445889;
        double r9445891 = fma(r9445885, r9445886, r9445890);
        return r9445891;
}

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

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

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

Reproduce

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