Average Error: 0.2 → 0.1
Time: 10.2s
Precision: 64
\[\left(x \cdot 3\right) \cdot y - z\]
\[\mathsf{fma}\left(y \cdot 3, x, -z\right)\]
\left(x \cdot 3\right) \cdot y - z
\mathsf{fma}\left(y \cdot 3, x, -z\right)
double f(double x, double y, double z) {
        double r449023 = x;
        double r449024 = 3.0;
        double r449025 = r449023 * r449024;
        double r449026 = y;
        double r449027 = r449025 * r449026;
        double r449028 = z;
        double r449029 = r449027 - r449028;
        return r449029;
}

double f(double x, double y, double z) {
        double r449030 = y;
        double r449031 = 3.0;
        double r449032 = r449030 * r449031;
        double r449033 = x;
        double r449034 = z;
        double r449035 = -r449034;
        double r449036 = fma(r449032, r449033, r449035);
        return r449036;
}

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. Simplified0.1

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

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

Reproduce

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