Average Error: 0.2 → 0.1
Time: 9.4s
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 r1221839 = x;
        double r1221840 = 3.0;
        double r1221841 = r1221839 * r1221840;
        double r1221842 = y;
        double r1221843 = r1221841 * r1221842;
        double r1221844 = z;
        double r1221845 = r1221843 - r1221844;
        return r1221845;
}

double f(double x, double y, double z) {
        double r1221846 = x;
        double r1221847 = 3.0;
        double r1221848 = r1221846 * r1221847;
        double r1221849 = y;
        double r1221850 = z;
        double r1221851 = -r1221850;
        double r1221852 = fma(r1221848, r1221849, r1221851);
        return r1221852;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.2
Target0.1
Herbie0.1
\[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.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 2019235 +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))