Average Error: 0.1 → 0.1
Time: 9.9s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(y, x, 3 \cdot \left(z \cdot z\right)\right)\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(y, x, 3 \cdot \left(z \cdot z\right)\right)
double f(double x, double y, double z) {
        double r320966 = x;
        double r320967 = y;
        double r320968 = r320966 * r320967;
        double r320969 = z;
        double r320970 = r320969 * r320969;
        double r320971 = r320968 + r320970;
        double r320972 = r320971 + r320970;
        double r320973 = r320972 + r320970;
        return r320973;
}

double f(double x, double y, double z) {
        double r320974 = y;
        double r320975 = x;
        double r320976 = 3.0;
        double r320977 = z;
        double r320978 = r320977 * r320977;
        double r320979 = r320976 * r320978;
        double r320980 = fma(r320974, r320975, r320979);
        return r320980;
}

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. Final simplification0.1

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

Reproduce

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