Average Error: 0.2 → 0.1
Time: 16.5s
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 r532569 = x;
        double r532570 = 3.0;
        double r532571 = r532569 * r532570;
        double r532572 = y;
        double r532573 = r532571 * r532572;
        double r532574 = z;
        double r532575 = r532573 - r532574;
        return r532575;
}

double f(double x, double y, double z) {
        double r532576 = x;
        double r532577 = y;
        double r532578 = 3.0;
        double r532579 = r532577 * r532578;
        double r532580 = z;
        double r532581 = -r532580;
        double r532582 = fma(r532576, r532579, r532581);
        return r532582;
}

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