Average Error: 0.2 → 0.1
Time: 17.4s
Precision: 64
\[\left(x \cdot 3\right) \cdot y - z\]
\[\mathsf{fma}\left(3, y \cdot x, -z\right)\]
\left(x \cdot 3\right) \cdot y - z
\mathsf{fma}\left(3, y \cdot x, -z\right)
double f(double x, double y, double z) {
        double r30965858 = x;
        double r30965859 = 3.0;
        double r30965860 = r30965858 * r30965859;
        double r30965861 = y;
        double r30965862 = r30965860 * r30965861;
        double r30965863 = z;
        double r30965864 = r30965862 - r30965863;
        return r30965864;
}

double f(double x, double y, double z) {
        double r30965865 = 3.0;
        double r30965866 = y;
        double r30965867 = x;
        double r30965868 = r30965866 * r30965867;
        double r30965869 = z;
        double r30965870 = -r30965869;
        double r30965871 = fma(r30965865, r30965868, r30965870);
        return r30965871;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.2
Target0.2
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. Using strategy rm
  4. Applied fma-neg0.1

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

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

Reproduce

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