Average Error: 0.1 → 0.1
Time: 15.7s
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 r462502 = x;
        double r462503 = r462502 * r462502;
        double r462504 = y;
        double r462505 = r462504 * r462504;
        double r462506 = r462503 + r462505;
        double r462507 = r462506 + r462505;
        double r462508 = r462507 + r462505;
        return r462508;
}

double f(double x, double y) {
        double r462509 = x;
        double r462510 = 3.0;
        double r462511 = y;
        double r462512 = r462510 * r462511;
        double r462513 = r462512 * r462511;
        double r462514 = fma(r462509, r462509, r462513);
        return r462514;
}

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. Using strategy rm
  4. Applied associate-*r*0.1

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(3 \cdot y\right) \cdot y}\right)\]
  5. Final simplification0.1

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

Reproduce

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