Average Error: 0.1 → 0.1
Time: 19.6s
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 r564321 = x;
        double r564322 = r564321 * r564321;
        double r564323 = y;
        double r564324 = r564323 * r564323;
        double r564325 = r564322 + r564324;
        double r564326 = r564325 + r564324;
        double r564327 = r564326 + r564324;
        return r564327;
}

double f(double x, double y) {
        double r564328 = x;
        double r564329 = 3.0;
        double r564330 = y;
        double r564331 = r564329 * r564330;
        double r564332 = r564331 * r564330;
        double r564333 = fma(r564328, r564328, r564332);
        return r564333;
}

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