Average Error: 0.1 → 0.1
Time: 4.2s
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 r513232 = x;
        double r513233 = y;
        double r513234 = r513232 * r513233;
        double r513235 = z;
        double r513236 = r513235 * r513235;
        double r513237 = r513234 + r513236;
        double r513238 = r513237 + r513236;
        double r513239 = r513238 + r513236;
        return r513239;
}

double f(double x, double y, double z) {
        double r513240 = x;
        double r513241 = y;
        double r513242 = z;
        double r513243 = r513242 * r513242;
        double r513244 = fma(r513240, r513241, r513243);
        double r513245 = r513244 + r513243;
        double r513246 = r513245 + r513243;
        return r513246;
}

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