Average Error: 0.1 → 0.1
Time: 4.8s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\left(\mathsf{fma}\left(x, y, z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\left(\mathsf{fma}\left(x, y, z \cdot z\right) + z \cdot z\right) + z \cdot z
double f(double x, double y, double z) {
        double r532236 = x;
        double r532237 = y;
        double r532238 = r532236 * r532237;
        double r532239 = z;
        double r532240 = r532239 * r532239;
        double r532241 = r532238 + r532240;
        double r532242 = r532241 + r532240;
        double r532243 = r532242 + r532240;
        return r532243;
}

double f(double x, double y, double z) {
        double r532244 = x;
        double r532245 = y;
        double r532246 = z;
        double r532247 = r532246 * r532246;
        double r532248 = fma(r532244, r532245, r532247);
        double r532249 = r532248 + r532247;
        double r532250 = r532249 + r532247;
        return r532250;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.1
Herbie0.1
\[\left(3 \cdot z\right) \cdot z + y \cdot x\]

Derivation

  1. Initial program 0.1

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

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

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

Reproduce

herbie shell --seed 2020036 +o rules:numerics
(FPCore (x y z)
  :name "Linear.Quaternion:$c/ from linear-1.19.1.3, A"
  :precision binary64

  :herbie-target
  (+ (* (* 3 z) z) (* y x))

  (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))