Average Error: 0.1 → 0.1
Time: 1.9s
Precision: 64
\[\left(x \cdot 3\right) \cdot y - z\]
\[\mathsf{fma}\left(3, x \cdot y, -z\right)\]
\left(x \cdot 3\right) \cdot y - z
\mathsf{fma}\left(3, x \cdot y, -z\right)
double f(double x, double y, double z) {
        double r733582 = x;
        double r733583 = 3.0;
        double r733584 = r733582 * r733583;
        double r733585 = y;
        double r733586 = r733584 * r733585;
        double r733587 = z;
        double r733588 = r733586 - r733587;
        return r733588;
}

double f(double x, double y, double z) {
        double r733589 = 3.0;
        double r733590 = x;
        double r733591 = y;
        double r733592 = r733590 * r733591;
        double r733593 = z;
        double r733594 = -r733593;
        double r733595 = fma(r733589, r733592, r733594);
        return r733595;
}

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. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{3 \cdot \left(x \cdot y\right)} - z\]
  3. Using strategy rm
  4. Applied fma-neg0.1

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

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

Reproduce

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