Average Error: 0.1 → 0.1
Time: 3.9s
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 r453458 = x;
        double r453459 = y;
        double r453460 = r453458 * r453459;
        double r453461 = z;
        double r453462 = r453461 * r453461;
        double r453463 = r453460 + r453462;
        double r453464 = r453463 + r453462;
        double r453465 = r453464 + r453462;
        return r453465;
}

double f(double x, double y, double z) {
        double r453466 = 3.0;
        double r453467 = z;
        double r453468 = r453467 * r453467;
        double r453469 = x;
        double r453470 = y;
        double r453471 = r453469 * r453470;
        double r453472 = fma(r453466, r453468, r453471);
        return r453472;
}

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