Average Error: 0.1 → 0.0
Time: 13.0s
Precision: 64
\[x \cdot \left(y + z\right) + z \cdot 5\]
\[\mathsf{fma}\left(z, 5, x \cdot \left(y + z\right)\right)\]
x \cdot \left(y + z\right) + z \cdot 5
\mathsf{fma}\left(z, 5, x \cdot \left(y + z\right)\right)
double f(double x, double y, double z) {
        double r417739 = x;
        double r417740 = y;
        double r417741 = z;
        double r417742 = r417740 + r417741;
        double r417743 = r417739 * r417742;
        double r417744 = 5.0;
        double r417745 = r417741 * r417744;
        double r417746 = r417743 + r417745;
        return r417746;
}

double f(double x, double y, double z) {
        double r417747 = z;
        double r417748 = 5.0;
        double r417749 = x;
        double r417750 = y;
        double r417751 = r417750 + r417747;
        double r417752 = r417749 * r417751;
        double r417753 = fma(r417747, r417748, r417752);
        return r417753;
}

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, y + z, z \cdot 5\right)}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt32.0

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, y + z, z \cdot 5\right)} \cdot \sqrt{\mathsf{fma}\left(x, y + z, z \cdot 5\right)}}\]
  5. Using strategy rm
  6. Applied *-un-lft-identity32.0

    \[\leadsto \sqrt{\mathsf{fma}\left(x, y + z, z \cdot 5\right)} \cdot \sqrt{\color{blue}{1 \cdot \mathsf{fma}\left(x, y + z, z \cdot 5\right)}}\]
  7. Applied sqrt-prod32.0

    \[\leadsto \sqrt{\mathsf{fma}\left(x, y + z, z \cdot 5\right)} \cdot \color{blue}{\left(\sqrt{1} \cdot \sqrt{\mathsf{fma}\left(x, y + z, z \cdot 5\right)}\right)}\]
  8. Applied *-un-lft-identity32.0

    \[\leadsto \sqrt{\color{blue}{1 \cdot \mathsf{fma}\left(x, y + z, z \cdot 5\right)}} \cdot \left(\sqrt{1} \cdot \sqrt{\mathsf{fma}\left(x, y + z, z \cdot 5\right)}\right)\]
  9. Applied sqrt-prod32.0

    \[\leadsto \color{blue}{\left(\sqrt{1} \cdot \sqrt{\mathsf{fma}\left(x, y + z, z \cdot 5\right)}\right)} \cdot \left(\sqrt{1} \cdot \sqrt{\mathsf{fma}\left(x, y + z, z \cdot 5\right)}\right)\]
  10. Applied swap-sqr32.0

    \[\leadsto \color{blue}{\left(\sqrt{1} \cdot \sqrt{1}\right) \cdot \left(\sqrt{\mathsf{fma}\left(x, y + z, z \cdot 5\right)} \cdot \sqrt{\mathsf{fma}\left(x, y + z, z \cdot 5\right)}\right)}\]
  11. Simplified32.0

    \[\leadsto \color{blue}{1} \cdot \left(\sqrt{\mathsf{fma}\left(x, y + z, z \cdot 5\right)} \cdot \sqrt{\mathsf{fma}\left(x, y + z, z \cdot 5\right)}\right)\]
  12. Simplified0.0

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

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

Reproduce

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