Average Error: 0.1 → 0.1
Time: 35.4s
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 r498302 = x;
        double r498303 = y;
        double r498304 = r498302 * r498303;
        double r498305 = z;
        double r498306 = r498305 * r498305;
        double r498307 = r498304 + r498306;
        double r498308 = r498307 + r498306;
        double r498309 = r498308 + r498306;
        return r498309;
}

double f(double x, double y, double z) {
        double r498310 = y;
        double r498311 = x;
        double r498312 = z;
        double r498313 = 3.0;
        double r498314 = r498313 * r498312;
        double r498315 = r498312 * r498314;
        double r498316 = fma(r498310, r498311, r498315);
        return r498316;
}

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 2020045 +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)))