Average Error: 0.2 → 0.1
Time: 11.2s
Precision: 64
\[\left(x \cdot 3\right) \cdot y - z\]
\[\mathsf{fma}\left(y \cdot 3, x, -z\right)\]
\left(x \cdot 3\right) \cdot y - z
\mathsf{fma}\left(y \cdot 3, x, -z\right)
double f(double x, double y, double z) {
        double r631892 = x;
        double r631893 = 3.0;
        double r631894 = r631892 * r631893;
        double r631895 = y;
        double r631896 = r631894 * r631895;
        double r631897 = z;
        double r631898 = r631896 - r631897;
        return r631898;
}

double f(double x, double y, double z) {
        double r631899 = y;
        double r631900 = 3.0;
        double r631901 = r631899 * r631900;
        double r631902 = x;
        double r631903 = z;
        double r631904 = -r631903;
        double r631905 = fma(r631901, r631902, r631904);
        return r631905;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.2
Target0.1
Herbie0.1
\[x \cdot \left(3 \cdot y\right) - z\]

Derivation

  1. Initial program 0.2

    \[\left(x \cdot 3\right) \cdot y - z\]
  2. Simplified0.1

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

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

Reproduce

herbie shell --seed 2019179 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, B"

  :herbie-target
  (- (* x (* 3.0 y)) z)

  (- (* (* x 3.0) y) z))