Average Error: 0.1 → 0.1
Time: 9.1s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(y, x, \left(z \cdot 3\right) \cdot z\right)\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(y, x, \left(z \cdot 3\right) \cdot z\right)
double f(double x, double y, double z) {
        double r399543 = x;
        double r399544 = y;
        double r399545 = r399543 * r399544;
        double r399546 = z;
        double r399547 = r399546 * r399546;
        double r399548 = r399545 + r399547;
        double r399549 = r399548 + r399547;
        double r399550 = r399549 + r399547;
        return r399550;
}

double f(double x, double y, double z) {
        double r399551 = y;
        double r399552 = x;
        double r399553 = z;
        double r399554 = 3.0;
        double r399555 = r399553 * r399554;
        double r399556 = r399555 * r399553;
        double r399557 = fma(r399551, r399552, r399556);
        return r399557;
}

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. Using strategy rm
  4. Applied fma-udef0.1

    \[\leadsto \color{blue}{3 \cdot \left(z \cdot z\right) + x \cdot y}\]
  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(y, x, z \cdot \left(z \cdot 3\right)\right)}\]
  7. Final simplification0.1

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

Reproduce

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