Average Error: 0.2 → 0.2
Time: 1.8s
Precision: 64
\[\left(x \cdot 3\right) \cdot y - z\]
\[\mathsf{fma}\left(x, 3 \cdot y, -z\right)\]
\left(x \cdot 3\right) \cdot y - z
\mathsf{fma}\left(x, 3 \cdot y, -z\right)
double f(double x, double y, double z) {
        double r782109 = x;
        double r782110 = 3.0;
        double r782111 = r782109 * r782110;
        double r782112 = y;
        double r782113 = r782111 * r782112;
        double r782114 = z;
        double r782115 = r782113 - r782114;
        return r782115;
}

double f(double x, double y, double z) {
        double r782116 = x;
        double r782117 = 3.0;
        double r782118 = y;
        double r782119 = r782117 * r782118;
        double r782120 = z;
        double r782121 = -r782120;
        double r782122 = fma(r782116, r782119, r782121);
        return r782122;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.2
Target0.2
Herbie0.2
\[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 associate-*l*0.2

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

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

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

Reproduce

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