Average Error: 0.2 → 0.1
Time: 11.7s
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 r809398 = x;
        double r809399 = 3.0;
        double r809400 = r809398 * r809399;
        double r809401 = y;
        double r809402 = r809400 * r809401;
        double r809403 = z;
        double r809404 = r809402 - r809403;
        return r809404;
}

double f(double x, double y, double z) {
        double r809405 = y;
        double r809406 = 3.0;
        double r809407 = r809405 * r809406;
        double r809408 = x;
        double r809409 = z;
        double r809410 = -r809409;
        double r809411 = fma(r809407, r809408, r809410);
        return r809411;
}

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 2019196 +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))