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 r548349 = x;
        double r548350 = y;
        double r548351 = r548349 * r548350;
        double r548352 = z;
        double r548353 = r548352 * r548352;
        double r548354 = r548351 + r548353;
        double r548355 = r548354 + r548353;
        double r548356 = r548355 + r548353;
        return r548356;
}

double f(double x, double y, double z) {
        double r548357 = 3.0;
        double r548358 = z;
        double r548359 = r548358 * r548358;
        double r548360 = x;
        double r548361 = y;
        double r548362 = r548360 * r548361;
        double r548363 = fma(r548357, r548359, r548362);
        return r548363;
}

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