Average Error: 0.1 → 0.0
Time: 3.0s
Precision: 64
\[x \cdot \left(y + z\right) + z \cdot 5\]
\[\mathsf{fma}\left(5, z, \mathsf{fma}\left(x, z, x \cdot y\right)\right)\]
x \cdot \left(y + z\right) + z \cdot 5
\mathsf{fma}\left(5, z, \mathsf{fma}\left(x, z, x \cdot y\right)\right)
double f(double x, double y, double z) {
        double r646711 = x;
        double r646712 = y;
        double r646713 = z;
        double r646714 = r646712 + r646713;
        double r646715 = r646711 * r646714;
        double r646716 = 5.0;
        double r646717 = r646713 * r646716;
        double r646718 = r646715 + r646717;
        return r646718;
}

double f(double x, double y, double z) {
        double r646719 = 5.0;
        double r646720 = z;
        double r646721 = x;
        double r646722 = y;
        double r646723 = r646721 * r646722;
        double r646724 = fma(r646721, r646720, r646723);
        double r646725 = fma(r646719, r646720, r646724);
        return r646725;
}

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. Using strategy rm
  3. Applied pow10.1

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

    \[\leadsto \color{blue}{{x}^{1}} \cdot {\left(y + z\right)}^{1} + z \cdot 5\]
  5. Applied pow-prod-down0.1

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

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

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

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

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

Reproduce

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