Average Error: 0.1 → 0.1
Time: 16.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 r80583 = x;
        double r80584 = 3.0;
        double r80585 = r80583 * r80584;
        double r80586 = y;
        double r80587 = r80585 * r80586;
        double r80588 = z;
        double r80589 = r80587 - r80588;
        return r80589;
}

double f(double x, double y, double z) {
        double r80590 = x;
        double r80591 = 3.0;
        double r80592 = r80590 * r80591;
        double r80593 = y;
        double r80594 = z;
        double r80595 = -r80594;
        double r80596 = fma(r80592, r80593, r80595);
        return r80596;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 0.1

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

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

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

Reproduce

herbie shell --seed 2019310 +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))