Average Error: 0.1 → 0.1
Time: 12.5s
Precision: 64
\[\left(x \cdot 3\right) \cdot y - z\]
\[\mathsf{fma}\left(x, y \cdot 3, -z\right)\]
\left(x \cdot 3\right) \cdot y - z
\mathsf{fma}\left(x, y \cdot 3, -z\right)
double f(double x, double y, double z) {
        double r30336628 = x;
        double r30336629 = 3.0;
        double r30336630 = r30336628 * r30336629;
        double r30336631 = y;
        double r30336632 = r30336630 * r30336631;
        double r30336633 = z;
        double r30336634 = r30336632 - r30336633;
        return r30336634;
}

double f(double x, double y, double z) {
        double r30336635 = x;
        double r30336636 = y;
        double r30336637 = 3.0;
        double r30336638 = r30336636 * r30336637;
        double r30336639 = z;
        double r30336640 = -r30336639;
        double r30336641 = fma(r30336635, r30336638, r30336640);
        return r30336641;
}

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 associate-*l*0.1

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

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

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

Reproduce

herbie shell --seed 2019171 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, B"

  :herbie-target
  (- (* x (* 3.0 y)) z)

  (- (* (* x 3.0) y) z))