Average Error: 0.1 → 0.1
Time: 3.3s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(3, y \cdot y, x \cdot x\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(3, y \cdot y, x \cdot x\right)
double f(double x, double y) {
        double r599745 = x;
        double r599746 = r599745 * r599745;
        double r599747 = y;
        double r599748 = r599747 * r599747;
        double r599749 = r599746 + r599748;
        double r599750 = r599749 + r599748;
        double r599751 = r599750 + r599748;
        return r599751;
}

double f(double x, double y) {
        double r599752 = 3.0;
        double r599753 = y;
        double r599754 = r599753 * r599753;
        double r599755 = x;
        double r599756 = r599755 * r599755;
        double r599757 = fma(r599752, r599754, r599756);
        return r599757;
}

Error

Bits error versus x

Bits error versus y

Target

Original0.1
Target0.1
Herbie0.1
\[x \cdot x + y \cdot \left(y + \left(y + y\right)\right)\]

Derivation

  1. Initial program 0.1

    \[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
  2. Simplified0.1

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

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

Reproduce

herbie shell --seed 2020083 +o rules:numerics
(FPCore (x y)
  :name "Linear.Quaternion:$c/ from linear-1.19.1.3, E"
  :precision binary64

  :herbie-target
  (+ (* x x) (* y (+ y (+ y y))))

  (+ (+ (+ (* x x) (* y y)) (* y y)) (* y y)))