Average Error: 0.1 → 0.1
Time: 1.9s
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 r876682 = x;
        double r876683 = 3.0;
        double r876684 = r876682 * r876683;
        double r876685 = y;
        double r876686 = r876684 * r876685;
        double r876687 = z;
        double r876688 = r876686 - r876687;
        return r876688;
}

double f(double x, double y, double z) {
        double r876689 = x;
        double r876690 = 3.0;
        double r876691 = r876689 * r876690;
        double r876692 = y;
        double r876693 = z;
        double r876694 = -r876693;
        double r876695 = fma(r876691, r876692, r876694);
        return r876695;
}

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