Average Error: 0.1 → 0.1
Time: 3.6s
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 r567478 = x;
        double r567479 = y;
        double r567480 = r567478 * r567479;
        double r567481 = z;
        double r567482 = r567481 * r567481;
        double r567483 = r567480 + r567482;
        double r567484 = r567483 + r567482;
        double r567485 = r567484 + r567482;
        return r567485;
}

double f(double x, double y, double z) {
        double r567486 = 3.0;
        double r567487 = z;
        double r567488 = r567487 * r567487;
        double r567489 = x;
        double r567490 = y;
        double r567491 = r567489 * r567490;
        double r567492 = fma(r567486, r567488, r567491);
        return r567492;
}

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