Average Error: 0.1 → 0.1
Time: 14.3s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(z, z \cdot 3, y \cdot x\right)\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(z, z \cdot 3, y \cdot x\right)
double f(double x, double y, double z) {
        double r292267 = x;
        double r292268 = y;
        double r292269 = r292267 * r292268;
        double r292270 = z;
        double r292271 = r292270 * r292270;
        double r292272 = r292269 + r292271;
        double r292273 = r292272 + r292271;
        double r292274 = r292273 + r292271;
        return r292274;
}

double f(double x, double y, double z) {
        double r292275 = z;
        double r292276 = 3.0;
        double r292277 = r292275 * r292276;
        double r292278 = y;
        double r292279 = x;
        double r292280 = r292278 * r292279;
        double r292281 = fma(r292275, r292277, r292280);
        return r292281;
}

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. Using strategy rm
  4. Applied associate-*r*0.1

    \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(3 \cdot z\right) \cdot z}\right)\]
  5. Taylor expanded around 0 0.1

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

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

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

Reproduce

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