Average Error: 0.1 → 0.1
Time: 12.7s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 3\right)\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 3\right)\right)
double f(double x, double y) {
        double r21304469 = x;
        double r21304470 = r21304469 * r21304469;
        double r21304471 = y;
        double r21304472 = r21304471 * r21304471;
        double r21304473 = r21304470 + r21304472;
        double r21304474 = r21304473 + r21304472;
        double r21304475 = r21304474 + r21304472;
        return r21304475;
}

double f(double x, double y) {
        double r21304476 = x;
        double r21304477 = y;
        double r21304478 = 3.0;
        double r21304479 = r21304477 * r21304478;
        double r21304480 = r21304477 * r21304479;
        double r21304481 = fma(r21304476, r21304476, r21304480);
        return r21304481;
}

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(x, x, \left(3 \cdot y\right) \cdot y\right)}\]
  3. Final simplification0.1

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

Reproduce

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

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

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