Average Error: 0.1 → 0.1
Time: 19.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 r370208 = x;
        double r370209 = y;
        double r370210 = r370208 * r370209;
        double r370211 = z;
        double r370212 = r370211 * r370211;
        double r370213 = r370210 + r370212;
        double r370214 = r370213 + r370212;
        double r370215 = r370214 + r370212;
        return r370215;
}

double f(double x, double y, double z) {
        double r370216 = y;
        double r370217 = x;
        double r370218 = 3.0;
        double r370219 = z;
        double r370220 = r370218 * r370219;
        double r370221 = r370220 * r370219;
        double r370222 = fma(r370216, r370217, r370221);
        return r370222;
}

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