Average Error: 0.1 → 0.1
Time: 30.6s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(z \cdot 3, z, x \cdot y\right)\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(z \cdot 3, z, x \cdot y\right)
double f(double x, double y, double z) {
        double r570963 = x;
        double r570964 = y;
        double r570965 = r570963 * r570964;
        double r570966 = z;
        double r570967 = r570966 * r570966;
        double r570968 = r570965 + r570967;
        double r570969 = r570968 + r570967;
        double r570970 = r570969 + r570967;
        return r570970;
}

double f(double x, double y, double z) {
        double r570971 = z;
        double r570972 = 3.0;
        double r570973 = r570971 * r570972;
        double r570974 = x;
        double r570975 = y;
        double r570976 = r570974 * r570975;
        double r570977 = fma(r570973, r570971, r570976);
        return r570977;
}

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}{3 \cdot {z}^{2} + x \cdot y}\]
  3. Simplified0.1

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

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

Reproduce

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