Average Error: 0.1 → 0.1
Time: 2.6s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(3, z \cdot z, x \cdot y\right)\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(3, z \cdot z, x \cdot y\right)
double f(double x, double y, double z) {
        double r458415 = x;
        double r458416 = y;
        double r458417 = r458415 * r458416;
        double r458418 = z;
        double r458419 = r458418 * r458418;
        double r458420 = r458417 + r458419;
        double r458421 = r458420 + r458419;
        double r458422 = r458421 + r458419;
        return r458422;
}

double f(double x, double y, double z) {
        double r458423 = 3.0;
        double r458424 = z;
        double r458425 = r458424 * r458424;
        double r458426 = x;
        double r458427 = y;
        double r458428 = r458426 * r458427;
        double r458429 = fma(r458423, r458425, r458428);
        return r458429;
}

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. Final simplification0.1

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

Reproduce

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