Average Error: 0.2 → 0.2
Time: 1.8s
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 r657485 = x;
        double r657486 = 3.0;
        double r657487 = r657485 * r657486;
        double r657488 = y;
        double r657489 = r657487 * r657488;
        double r657490 = z;
        double r657491 = r657489 - r657490;
        return r657491;
}

double f(double x, double y, double z) {
        double r657492 = x;
        double r657493 = 3.0;
        double r657494 = r657492 * r657493;
        double r657495 = y;
        double r657496 = z;
        double r657497 = -r657496;
        double r657498 = fma(r657494, r657495, r657497);
        return r657498;
}

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