Average Error: 0.1 → 0.1
Time: 39.5s
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 r21432158 = x;
        double r21432159 = y;
        double r21432160 = r21432158 * r21432159;
        double r21432161 = z;
        double r21432162 = r21432161 * r21432161;
        double r21432163 = r21432160 + r21432162;
        double r21432164 = r21432163 + r21432162;
        double r21432165 = r21432164 + r21432162;
        return r21432165;
}

double f(double x, double y, double z) {
        double r21432166 = 3.0;
        double r21432167 = z;
        double r21432168 = r21432167 * r21432167;
        double r21432169 = x;
        double r21432170 = y;
        double r21432171 = r21432169 * r21432170;
        double r21432172 = fma(r21432166, r21432168, r21432171);
        return r21432172;
}

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