Average Error: 0.1 → 0.1
Time: 3.6s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(3, y \cdot y, x \cdot x\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(3, y \cdot y, x \cdot x\right)
double f(double x, double y) {
        double r506068 = x;
        double r506069 = r506068 * r506068;
        double r506070 = y;
        double r506071 = r506070 * r506070;
        double r506072 = r506069 + r506071;
        double r506073 = r506072 + r506071;
        double r506074 = r506073 + r506071;
        return r506074;
}

double f(double x, double y) {
        double r506075 = 3.0;
        double r506076 = y;
        double r506077 = r506076 * r506076;
        double r506078 = x;
        double r506079 = r506078 * r506078;
        double r506080 = fma(r506075, r506077, r506079);
        return r506080;
}

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(3, y \cdot y, x \cdot x\right)}\]
  3. Final simplification0.1

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

Reproduce

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