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\]
\[\left(\mathsf{fma}\left(x, y, z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\left(\mathsf{fma}\left(x, y, z \cdot z\right) + z \cdot z\right) + z \cdot z
double f(double x, double y, double z) {
        double r414367 = x;
        double r414368 = y;
        double r414369 = r414367 * r414368;
        double r414370 = z;
        double r414371 = r414370 * r414370;
        double r414372 = r414369 + r414371;
        double r414373 = r414372 + r414371;
        double r414374 = r414373 + r414371;
        return r414374;
}

double f(double x, double y, double z) {
        double r414375 = x;
        double r414376 = y;
        double r414377 = z;
        double r414378 = r414377 * r414377;
        double r414379 = fma(r414375, r414376, r414378);
        double r414380 = r414379 + r414378;
        double r414381 = r414380 + r414378;
        return r414381;
}

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. Using strategy rm
  3. Applied fma-def0.1

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

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

Reproduce

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