Average Error: 0.1 → 0.1
Time: 2.0s
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 r721145 = x;
        double r721146 = 3.0;
        double r721147 = r721145 * r721146;
        double r721148 = y;
        double r721149 = r721147 * r721148;
        double r721150 = z;
        double r721151 = r721149 - r721150;
        return r721151;
}

double f(double x, double y, double z) {
        double r721152 = x;
        double r721153 = 3.0;
        double r721154 = r721152 * r721153;
        double r721155 = y;
        double r721156 = z;
        double r721157 = -r721156;
        double r721158 = fma(r721154, r721155, r721157);
        return r721158;
}

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