Average Error: 0.1 → 0.1
Time: 21.6s
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 r615721 = x;
        double r615722 = 3.0;
        double r615723 = r615721 * r615722;
        double r615724 = y;
        double r615725 = r615723 * r615724;
        double r615726 = z;
        double r615727 = r615725 - r615726;
        return r615727;
}

double f(double x, double y, double z) {
        double r615728 = x;
        double r615729 = y;
        double r615730 = 3.0;
        double r615731 = r615729 * r615730;
        double r615732 = z;
        double r615733 = -r615732;
        double r615734 = fma(r615728, r615731, r615733);
        return r615734;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.1
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. 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 2019306 +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))