Average Error: 0.1 → 0.1
Time: 34.3s
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 r30127356 = x;
        double r30127357 = 3.0;
        double r30127358 = r30127356 * r30127357;
        double r30127359 = y;
        double r30127360 = r30127358 * r30127359;
        double r30127361 = z;
        double r30127362 = r30127360 - r30127361;
        return r30127362;
}

double f(double x, double y, double z) {
        double r30127363 = x;
        double r30127364 = 3.0;
        double r30127365 = r30127363 * r30127364;
        double r30127366 = y;
        double r30127367 = z;
        double r30127368 = -r30127367;
        double r30127369 = fma(r30127365, r30127366, r30127368);
        return r30127369;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.2
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(x \cdot 3, y, -z\right)\]

Reproduce

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