Average Error: 0.2 → 0.2
Time: 11.3s
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 r811015 = x;
        double r811016 = 3.0;
        double r811017 = r811015 * r811016;
        double r811018 = y;
        double r811019 = r811017 * r811018;
        double r811020 = z;
        double r811021 = r811019 - r811020;
        return r811021;
}

double f(double x, double y, double z) {
        double r811022 = x;
        double r811023 = 3.0;
        double r811024 = r811022 * r811023;
        double r811025 = y;
        double r811026 = z;
        double r811027 = -r811026;
        double r811028 = fma(r811024, r811025, r811027);
        return r811028;
}

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 2020043 +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))