Average Error: 0.1 → 0.1
Time: 7.4s
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 r8823501 = x;
        double r8823502 = r8823501 * r8823501;
        double r8823503 = y;
        double r8823504 = r8823503 * r8823503;
        double r8823505 = r8823502 + r8823504;
        double r8823506 = r8823505 + r8823504;
        double r8823507 = r8823506 + r8823504;
        return r8823507;
}

double f(double x, double y) {
        double r8823508 = x;
        double r8823509 = y;
        double r8823510 = 3.0;
        double r8823511 = r8823509 * r8823510;
        double r8823512 = r8823509 * r8823511;
        double r8823513 = fma(r8823508, r8823508, r8823512);
        return r8823513;
}

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