Average Error: 0.1 → 0.1
Time: 26.3s
Precision: 64
\[\left(x \cdot 3\right) \cdot y - z\]
\[\mathsf{fma}\left(3 \cdot x, y, -z\right)\]
\left(x \cdot 3\right) \cdot y - z
\mathsf{fma}\left(3 \cdot x, y, -z\right)
double f(double x, double y, double z) {
        double r27583714 = x;
        double r27583715 = 3.0;
        double r27583716 = r27583714 * r27583715;
        double r27583717 = y;
        double r27583718 = r27583716 * r27583717;
        double r27583719 = z;
        double r27583720 = r27583718 - r27583719;
        return r27583720;
}

double f(double x, double y, double z) {
        double r27583721 = 3.0;
        double r27583722 = x;
        double r27583723 = r27583721 * r27583722;
        double r27583724 = y;
        double r27583725 = z;
        double r27583726 = -r27583725;
        double r27583727 = fma(r27583723, r27583724, r27583726);
        return r27583727;
}

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(3 \cdot x, y, -z\right)\]

Reproduce

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