Average Error: 0.1 → 0.1
Time: 1.0m
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(x, y, \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(x, y, \left(z \cdot 3\right) \cdot z\right)
double f(double x, double y, double z) {
        double r16414544 = x;
        double r16414545 = y;
        double r16414546 = r16414544 * r16414545;
        double r16414547 = z;
        double r16414548 = r16414547 * r16414547;
        double r16414549 = r16414546 + r16414548;
        double r16414550 = r16414549 + r16414548;
        double r16414551 = r16414550 + r16414548;
        return r16414551;
}

double f(double x, double y, double z) {
        double r16414552 = x;
        double r16414553 = y;
        double r16414554 = z;
        double r16414555 = 3.0;
        double r16414556 = r16414554 * r16414555;
        double r16414557 = r16414556 * r16414554;
        double r16414558 = fma(r16414552, r16414553, r16414557);
        return r16414558;
}

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(z, z \cdot 3, y \cdot x\right)}\]
  3. Taylor expanded around 0 0.1

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

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

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

Reproduce

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