Average Error: 0.1 → 0.1
Time: 14.1s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, \left(3 \cdot y\right) \cdot y\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, \left(3 \cdot y\right) \cdot y\right)
double f(double x, double y) {
        double r404467 = x;
        double r404468 = r404467 * r404467;
        double r404469 = y;
        double r404470 = r404469 * r404469;
        double r404471 = r404468 + r404470;
        double r404472 = r404471 + r404470;
        double r404473 = r404472 + r404470;
        return r404473;
}

double f(double x, double y) {
        double r404474 = x;
        double r404475 = 3.0;
        double r404476 = y;
        double r404477 = r404475 * r404476;
        double r404478 = r404477 * r404476;
        double r404479 = fma(r404474, r404474, r404478);
        return r404479;
}

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

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

Reproduce

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