Average Error: 0.1 → 0.1
Time: 7.9s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(3, {z}^{2}, y \cdot x\right)\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(3, {z}^{2}, y \cdot x\right)
double f(double x, double y, double z) {
        double r356913 = x;
        double r356914 = y;
        double r356915 = r356913 * r356914;
        double r356916 = z;
        double r356917 = r356916 * r356916;
        double r356918 = r356915 + r356917;
        double r356919 = r356918 + r356917;
        double r356920 = r356919 + r356917;
        return r356920;
}

double f(double x, double y, double z) {
        double r356921 = 3.0;
        double r356922 = z;
        double r356923 = 2.0;
        double r356924 = pow(r356922, r356923);
        double r356925 = y;
        double r356926 = x;
        double r356927 = r356925 * r356926;
        double r356928 = fma(r356921, r356924, r356927);
        return r356928;
}

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

    \[\leadsto \color{blue}{3 \cdot {z}^{2} + x \cdot y}\]
  4. Simplified0.1

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

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

Reproduce

herbie shell --seed 2019198 +o rules:numerics
(FPCore (x y z)
  :name "Linear.Quaternion:$c/ from linear-1.19.1.3, A"

  :herbie-target
  (+ (* (* 3.0 z) z) (* y x))

  (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))