Average Error: 0.1 → 0.1
Time: 4.1s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(3, z \cdot z, x \cdot y\right)\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(3, z \cdot z, x \cdot y\right)
double f(double x, double y, double z) {
        double r424394 = x;
        double r424395 = y;
        double r424396 = r424394 * r424395;
        double r424397 = z;
        double r424398 = r424397 * r424397;
        double r424399 = r424396 + r424398;
        double r424400 = r424399 + r424398;
        double r424401 = r424400 + r424398;
        return r424401;
}

double f(double x, double y, double z) {
        double r424402 = 3.0;
        double r424403 = z;
        double r424404 = r424403 * r424403;
        double r424405 = x;
        double r424406 = y;
        double r424407 = r424405 * r424406;
        double r424408 = fma(r424402, r424404, r424407);
        return r424408;
}

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. Simplified0.1

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

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

Reproduce

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