Average Error: 0.1 → 0.1
Time: 6.1s
Precision: 64
\[\left(x \cdot 3.0\right) \cdot y - z\]
\[\mathsf{fma}\left(x \cdot 3.0, y, -z\right)\]
\left(x \cdot 3.0\right) \cdot y - z
\mathsf{fma}\left(x \cdot 3.0, y, -z\right)
double f(double x, double y, double z) {
        double r13816127 = x;
        double r13816128 = 3.0;
        double r13816129 = r13816127 * r13816128;
        double r13816130 = y;
        double r13816131 = r13816129 * r13816130;
        double r13816132 = z;
        double r13816133 = r13816131 - r13816132;
        return r13816133;
}

double f(double x, double y, double z) {
        double r13816134 = x;
        double r13816135 = 3.0;
        double r13816136 = r13816134 * r13816135;
        double r13816137 = y;
        double r13816138 = z;
        double r13816139 = -r13816138;
        double r13816140 = fma(r13816136, r13816137, r13816139);
        return r13816140;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.2
Herbie0.1
\[x \cdot \left(3.0 \cdot y\right) - z\]

Derivation

  1. Initial program 0.1

    \[\left(x \cdot 3.0\right) \cdot y - z\]
  2. Using strategy rm
  3. Applied fma-neg0.1

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

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

Reproduce

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