Average Error: 0.1 → 0.1
Time: 16.5s
Precision: 64
\[\left(x \cdot 3.0\right) \cdot y - z\]
\[\mathsf{fma}\left(x \cdot 3.0, y, -z\right)\]
\left(x \cdot 3.0\right) \cdot y - z
\mathsf{fma}\left(x \cdot 3.0, y, -z\right)
double f(double x, double y, double z) {
        double r31940246 = x;
        double r31940247 = 3.0;
        double r31940248 = r31940246 * r31940247;
        double r31940249 = y;
        double r31940250 = r31940248 * r31940249;
        double r31940251 = z;
        double r31940252 = r31940250 - r31940251;
        return r31940252;
}

double f(double x, double y, double z) {
        double r31940253 = x;
        double r31940254 = 3.0;
        double r31940255 = r31940253 * r31940254;
        double r31940256 = y;
        double r31940257 = z;
        double r31940258 = -r31940257;
        double r31940259 = fma(r31940255, r31940256, r31940258);
        return r31940259;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.1
Herbie0.1
\[x \cdot \left(3.0 \cdot y\right) - z\]

Derivation

  1. Initial program 0.1

    \[\left(x \cdot 3.0\right) \cdot y - z\]
  2. Using strategy rm
  3. Applied fma-neg0.1

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

    \[\leadsto \mathsf{fma}\left(x \cdot 3.0, 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))