Average Error: 0.1 → 0.1
Time: 4.4s
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 r517518 = x;
        double r517519 = y;
        double r517520 = r517518 * r517519;
        double r517521 = z;
        double r517522 = r517521 * r517521;
        double r517523 = r517520 + r517522;
        double r517524 = r517523 + r517522;
        double r517525 = r517524 + r517522;
        return r517525;
}

double f(double x, double y, double z) {
        double r517526 = 3.0;
        double r517527 = z;
        double r517528 = r517527 * r517527;
        double r517529 = x;
        double r517530 = y;
        double r517531 = r517529 * r517530;
        double r517532 = fma(r517526, r517528, r517531);
        return r517532;
}

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