Average Error: 0.2 → 0.2
Time: 15.5s
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 r35987033 = x;
        double r35987034 = 3.0;
        double r35987035 = r35987033 * r35987034;
        double r35987036 = y;
        double r35987037 = r35987035 * r35987036;
        double r35987038 = z;
        double r35987039 = r35987037 - r35987038;
        return r35987039;
}

double f(double x, double y, double z) {
        double r35987040 = x;
        double r35987041 = 3.0;
        double r35987042 = r35987040 * r35987041;
        double r35987043 = y;
        double r35987044 = z;
        double r35987045 = -r35987044;
        double r35987046 = fma(r35987042, r35987043, r35987045);
        return r35987046;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.2
Target0.2
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 2019170 +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))