Average Error: 0.1 → 0.1
Time: 3.2s
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 r2011618 = x;
        double r2011619 = r2011618 * r2011618;
        double r2011620 = y;
        double r2011621 = r2011620 * r2011620;
        double r2011622 = r2011619 + r2011621;
        double r2011623 = r2011622 + r2011621;
        double r2011624 = r2011623 + r2011621;
        return r2011624;
}

double f(double x, double y) {
        double r2011625 = 3.0;
        double r2011626 = y;
        double r2011627 = r2011626 * r2011626;
        double r2011628 = x;
        double r2011629 = r2011628 * r2011628;
        double r2011630 = fma(r2011625, r2011627, r2011629);
        return r2011630;
}

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