Average Error: 0.1 → 0.1
Time: 15.6s
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 r22375402 = x;
        double r22375403 = r22375402 * r22375402;
        double r22375404 = y;
        double r22375405 = r22375404 * r22375404;
        double r22375406 = r22375403 + r22375405;
        double r22375407 = r22375406 + r22375405;
        double r22375408 = r22375407 + r22375405;
        return r22375408;
}

double f(double x, double y) {
        double r22375409 = x;
        double r22375410 = y;
        double r22375411 = 3.0;
        double r22375412 = r22375410 * r22375411;
        double r22375413 = r22375410 * r22375412;
        double r22375414 = fma(r22375409, r22375409, r22375413);
        return r22375414;
}

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