Average Error: 0.1 → 0.1
Time: 7.8s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, 3 \cdot \left(y \cdot y\right)\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, 3 \cdot \left(y \cdot y\right)\right)
double f(double x, double y) {
        double r328466 = x;
        double r328467 = r328466 * r328466;
        double r328468 = y;
        double r328469 = r328468 * r328468;
        double r328470 = r328467 + r328469;
        double r328471 = r328470 + r328469;
        double r328472 = r328471 + r328469;
        return r328472;
}

double f(double x, double y) {
        double r328473 = x;
        double r328474 = 3.0;
        double r328475 = y;
        double r328476 = r328475 * r328475;
        double r328477 = r328474 * r328476;
        double r328478 = fma(r328473, r328473, r328477);
        return r328478;
}

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

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

Reproduce

herbie shell --seed 2019305 +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)))