Average Error: 0.2 → 0.2
Time: 1.7s
Precision: 64
\[\left(x \cdot 3\right) \cdot y - z\]
\[\mathsf{fma}\left(x \cdot 3, y, -z\right)\]
\left(x \cdot 3\right) \cdot y - z
\mathsf{fma}\left(x \cdot 3, y, -z\right)
double f(double x, double y, double z) {
        double r718904 = x;
        double r718905 = 3.0;
        double r718906 = r718904 * r718905;
        double r718907 = y;
        double r718908 = r718906 * r718907;
        double r718909 = z;
        double r718910 = r718908 - r718909;
        return r718910;
}

double f(double x, double y, double z) {
        double r718911 = x;
        double r718912 = 3.0;
        double r718913 = r718911 * r718912;
        double r718914 = y;
        double r718915 = z;
        double r718916 = -r718915;
        double r718917 = fma(r718913, r718914, r718916);
        return r718917;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 0.2

    \[\left(x \cdot 3\right) \cdot y - z\]
  2. Using strategy rm
  3. Applied fma-neg0.2

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

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

Reproduce

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

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

  (- (* (* x 3) y) z))