Average Error: 0.1 → 0.1
Time: 10.5s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(2, z \cdot z, x \cdot y\right) + z \cdot z\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(2, z \cdot z, x \cdot y\right) + z \cdot z
double f(double x, double y, double z) {
        double r713875 = x;
        double r713876 = y;
        double r713877 = r713875 * r713876;
        double r713878 = z;
        double r713879 = r713878 * r713878;
        double r713880 = r713877 + r713879;
        double r713881 = r713880 + r713879;
        double r713882 = r713881 + r713879;
        return r713882;
}

double f(double x, double y, double z) {
        double r713883 = 2.0;
        double r713884 = z;
        double r713885 = r713884 * r713884;
        double r713886 = x;
        double r713887 = y;
        double r713888 = r713886 * r713887;
        double r713889 = fma(r713883, r713885, r713888);
        double r713890 = r713889 + r713885;
        return r713890;
}

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. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{\left(2 \cdot {z}^{2} + x \cdot y\right)} + z \cdot z\]
  3. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(2, z \cdot z, x \cdot y\right)} + z \cdot z\]
  4. Final simplification0.1

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

Reproduce

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