Average Error: 0.1 → 0.1
Time: 15.8s
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 r19685311 = x;
        double r19685312 = y;
        double r19685313 = r19685311 * r19685312;
        double r19685314 = z;
        double r19685315 = r19685314 * r19685314;
        double r19685316 = r19685313 + r19685315;
        double r19685317 = r19685316 + r19685315;
        double r19685318 = r19685317 + r19685315;
        return r19685318;
}

double f(double x, double y, double z) {
        double r19685319 = 3.0;
        double r19685320 = z;
        double r19685321 = r19685320 * r19685320;
        double r19685322 = x;
        double r19685323 = y;
        double r19685324 = r19685322 * r19685323;
        double r19685325 = fma(r19685319, r19685321, r19685324);
        return r19685325;
}

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 2019172 +o rules:numerics
(FPCore (x y z)
  :name "Linear.Quaternion:$c/ from linear-1.19.1.3, A"

  :herbie-target
  (+ (* (* 3.0 z) z) (* y x))

  (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))