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 r692758 = x;
        double r692759 = 3.0;
        double r692760 = r692758 * r692759;
        double r692761 = y;
        double r692762 = r692760 * r692761;
        double r692763 = z;
        double r692764 = r692762 - r692763;
        return r692764;
}

double f(double x, double y, double z) {
        double r692765 = x;
        double r692766 = 3.0;
        double r692767 = r692765 * r692766;
        double r692768 = y;
        double r692769 = z;
        double r692770 = -r692769;
        double r692771 = fma(r692767, r692768, r692770);
        return r692771;
}

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