Average Error: 0.1 → 0.1
Time: 16.5s
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 r21674585 = x;
        double r21674586 = r21674585 * r21674585;
        double r21674587 = y;
        double r21674588 = r21674587 * r21674587;
        double r21674589 = r21674586 + r21674588;
        double r21674590 = r21674589 + r21674588;
        double r21674591 = r21674590 + r21674588;
        return r21674591;
}

double f(double x, double y) {
        double r21674592 = x;
        double r21674593 = y;
        double r21674594 = 3.0;
        double r21674595 = r21674593 * r21674594;
        double r21674596 = r21674593 * r21674595;
        double r21674597 = fma(r21674592, r21674592, r21674596);
        return r21674597;
}

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