Average Error: 0.1 → 0.1
Time: 1.7s
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 r700308 = x;
        double r700309 = 3.0;
        double r700310 = r700308 * r700309;
        double r700311 = y;
        double r700312 = r700310 * r700311;
        double r700313 = z;
        double r700314 = r700312 - r700313;
        return r700314;
}

double f(double x, double y, double z) {
        double r700315 = x;
        double r700316 = 3.0;
        double r700317 = r700315 * r700316;
        double r700318 = y;
        double r700319 = z;
        double r700320 = -r700319;
        double r700321 = fma(r700317, r700318, r700320);
        return r700321;
}

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

Reproduce

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