Average Error: 0.1 → 0.0
Time: 8.6s
Precision: 64
\[x \cdot \left(y + z\right) + z \cdot 5\]
\[\mathsf{fma}\left(z, 5, x \cdot y + z \cdot x\right)\]
x \cdot \left(y + z\right) + z \cdot 5
\mathsf{fma}\left(z, 5, x \cdot y + z \cdot x\right)
double f(double x, double y, double z) {
        double r358190 = x;
        double r358191 = y;
        double r358192 = z;
        double r358193 = r358191 + r358192;
        double r358194 = r358190 * r358193;
        double r358195 = 5.0;
        double r358196 = r358192 * r358195;
        double r358197 = r358194 + r358196;
        return r358197;
}

double f(double x, double y, double z) {
        double r358198 = z;
        double r358199 = 5.0;
        double r358200 = x;
        double r358201 = y;
        double r358202 = r358200 * r358201;
        double r358203 = r358198 * r358200;
        double r358204 = r358202 + r358203;
        double r358205 = fma(r358198, r358199, r358204);
        return r358205;
}

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

    \[\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. Taylor expanded around 0 0.1

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, 5, x \cdot \left(y + z\right)\right)}\]
  7. Using strategy rm
  8. Applied distribute-lft-in0.0

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

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

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

Reproduce

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