Average Error: 0.1 → 0.1
Time: 15.9s
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 r394735 = x;
        double r394736 = r394735 * r394735;
        double r394737 = y;
        double r394738 = r394737 * r394737;
        double r394739 = r394736 + r394738;
        double r394740 = r394739 + r394738;
        double r394741 = r394740 + r394738;
        return r394741;
}

double f(double x, double y) {
        double r394742 = x;
        double r394743 = 3.0;
        double r394744 = y;
        double r394745 = r394743 * r394744;
        double r394746 = r394745 * r394744;
        double r394747 = fma(r394742, r394742, r394746);
        return r394747;
}

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