Average Error: 0.1 → 0.1
Time: 18.6s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(y, x, z \cdot \left(3 \cdot z\right)\right)\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(y, x, z \cdot \left(3 \cdot z\right)\right)
double f(double x, double y, double z) {
        double r343450 = x;
        double r343451 = y;
        double r343452 = r343450 * r343451;
        double r343453 = z;
        double r343454 = r343453 * r343453;
        double r343455 = r343452 + r343454;
        double r343456 = r343455 + r343454;
        double r343457 = r343456 + r343454;
        return r343457;
}

double f(double x, double y, double z) {
        double r343458 = y;
        double r343459 = x;
        double r343460 = z;
        double r343461 = 3.0;
        double r343462 = r343461 * r343460;
        double r343463 = r343460 * r343462;
        double r343464 = fma(r343458, r343459, r343463);
        return r343464;
}

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 \mathsf{fma}\left(y, x, \color{blue}{3 \cdot {z}^{2}}\right)\]
  4. Simplified0.1

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

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

Reproduce

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