Average Error: 0.1 → 0.1
Time: 11.8s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(y, x, \left(3 \cdot z\right) \cdot z\right)\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(y, x, \left(3 \cdot z\right) \cdot z\right)
double f(double x, double y, double z) {
        double r416506 = x;
        double r416507 = y;
        double r416508 = r416506 * r416507;
        double r416509 = z;
        double r416510 = r416509 * r416509;
        double r416511 = r416508 + r416510;
        double r416512 = r416511 + r416510;
        double r416513 = r416512 + r416510;
        return r416513;
}

double f(double x, double y, double z) {
        double r416514 = y;
        double r416515 = x;
        double r416516 = 3.0;
        double r416517 = z;
        double r416518 = r416516 * r416517;
        double r416519 = r416518 * r416517;
        double r416520 = fma(r416514, r416515, r416519);
        return r416520;
}

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(y, x, 3 \cdot \left(z \cdot z\right)\right)}\]
  3. Using strategy rm
  4. Applied associate-*r*0.1

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

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

Reproduce

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