Average Error: 0.1 → 0.1
Time: 15.0s
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 r175159 = x;
        double r175160 = y;
        double r175161 = r175159 * r175160;
        double r175162 = z;
        double r175163 = r175162 * r175162;
        double r175164 = r175161 + r175163;
        double r175165 = r175164 + r175163;
        double r175166 = r175165 + r175163;
        return r175166;
}

double f(double x, double y, double z) {
        double r175167 = y;
        double r175168 = x;
        double r175169 = 3.0;
        double r175170 = z;
        double r175171 = r175169 * r175170;
        double r175172 = r175171 * r175170;
        double r175173 = fma(r175167, r175168, r175172);
        return r175173;
}

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