Average Error: 0.1 → 0.1
Time: 23.8s
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 r24019428 = x;
        double r24019429 = r24019428 * r24019428;
        double r24019430 = y;
        double r24019431 = r24019430 * r24019430;
        double r24019432 = r24019429 + r24019431;
        double r24019433 = r24019432 + r24019431;
        double r24019434 = r24019433 + r24019431;
        return r24019434;
}

double f(double x, double y) {
        double r24019435 = x;
        double r24019436 = y;
        double r24019437 = 3.0;
        double r24019438 = r24019436 * r24019437;
        double r24019439 = r24019436 * r24019438;
        double r24019440 = fma(r24019435, r24019435, r24019439);
        return r24019440;
}

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