Average Error: 0.2 → 0.1
Time: 14.9s
Precision: 64
\[\left(x \cdot 3\right) \cdot y - z\]
\[\mathsf{fma}\left(x, y \cdot 3, -z\right)\]
\left(x \cdot 3\right) \cdot y - z
\mathsf{fma}\left(x, y \cdot 3, -z\right)
double f(double x, double y, double z) {
        double r469325 = x;
        double r469326 = 3.0;
        double r469327 = r469325 * r469326;
        double r469328 = y;
        double r469329 = r469327 * r469328;
        double r469330 = z;
        double r469331 = r469329 - r469330;
        return r469331;
}

double f(double x, double y, double z) {
        double r469332 = x;
        double r469333 = y;
        double r469334 = 3.0;
        double r469335 = r469333 * r469334;
        double r469336 = z;
        double r469337 = -r469336;
        double r469338 = fma(r469332, r469335, r469337);
        return r469338;
}

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. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{3 \cdot \left(x \cdot y\right) - z}\]
  3. Simplified0.1

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

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

Reproduce

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