Average Error: 0.1 → 0.1
Time: 3.7s
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 r559062 = x;
        double r559063 = y;
        double r559064 = r559062 * r559063;
        double r559065 = z;
        double r559066 = r559065 * r559065;
        double r559067 = r559064 + r559066;
        double r559068 = r559067 + r559066;
        double r559069 = r559068 + r559066;
        return r559069;
}

double f(double x, double y, double z) {
        double r559070 = 3.0;
        double r559071 = z;
        double r559072 = r559071 * r559071;
        double r559073 = x;
        double r559074 = y;
        double r559075 = r559073 * r559074;
        double r559076 = fma(r559070, r559072, r559075);
        return r559076;
}

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